SVG Text

SVG Text

In [1]:
from IPython.display import HTML

Write your name

In [2]:
HTML("""
    <html>
        <body>
            <svg width="100" height="100">
                <text x="10" y="10">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[2]:
John

Make your name in red color

In [3]:
HTML("""
    <html>
        <body>
            <svg width="100" height="100">
                <text x="10" y="10" fill = "red">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[3]:
John

Make it bigger

In [4]:
HTML("""
    <html>
        <body>
            <svg width="100" height="100">
                <text x="10" y="10" fill = "red" font-size="40">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[4]:
John
In [5]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="50" y="50" fill = "red" font-size="40">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[5]:
John

Make it bold

In [6]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="50" y="50" fill = "red" font-size="40" font-weight="bold">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[6]:
John

Rotate your name by zero degree

In [7]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="50" y="50" fill = "red" font-size="40" font-weight="bold" transform="rotate(0)" >
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[7]:
John

Rotate your name by 30 degree

In [8]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="50" y="50" fill = "red" font-size="40" font-weight="bold" transform="rotate(30)" >
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[8]:
John
In [9]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="50" y="50" fill = "red" font-size="40" font-weight="bold" transform="rotate(50)" >
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[9]:
John
#rotation is done around the point 0,0 #transform="rotate(100)" #rotation is done around the point 10,10 #
In [10]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="50" y="50" fill = "red" font-size="40" font-weight="bold" transform="rotate(100,50,50)">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[10]:
John
In [11]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="50" y="50" fill = "red" font-size="40" font-weight="bold" transform="rotate(180,50,50)">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[11]:
John
In [12]:
HTML("""
    <html>
        <body>
            <svg width="200" height="200">
                <text x="100" y="50" fill = "red" font-size="40" font-weight="bold" transform="rotate(180,100,50)">
                    John
                </text>
            </svg>
        </body>
    </html>
""")
Out[12]:
John

Write text cat sat on the chair

In [13]:
HTML("""
    <html>
        <body>
            <svg width="500" height="200">
                <text x="100" y="50" font-size="30">
                    Cat sat on the chair
                </text>
            </svg>
        </body>
    </html>
""")
Out[13]:
Cat sat on the chair

Make only cat word in red

In [14]:
HTML("""
    <html>
        <body>
            <svg width="500" height="200">
                <text x="100" y="50" font-size="30">
                    <tspan fill = "red">
                        Cat 
                    </tspan>
                    sat on the chair
                </text>
            </svg>
        </body>
    </html>
""")
Out[14]:
Cat sat on the chair

Move chair word down

In [15]:
HTML("""
    <html>
        <body>
            <svg width="500" height="200">
                <text x="100" y="100" font-size="30">
                    Cat sat on the
                    <tspan dy="20" fill = "red">
                        chair 
                    </tspan>
                     
                </text>
            </svg>
        </body>
    </html>
""")
Out[15]:
Cat sat on the chair
In [16]:
HTML("""
    <html>
        <body>
            <svg width="500" height="200">
                <text x="100" y="100" font-size="30">
                    Cat sat on the
                    <tspan dy="-20" fill = "red">
                        chair 
                    </tspan>
                     
                </text>
            </svg>
        </body>
    </html>
""")
Out[16]:
Cat sat on the chair
In [17]:
HTML("""
    <html>
        <body>
            <svg width="500" height="200">
                <text x="100" y="100" font-size="30">
                    sat on the
                    <tspan dy="-20" fill = "red">
                        chair 
                    </tspan>
                     
                </text>
                <image href="/static/images/nutan/blog/svg/svg-text/cat.jpg" height="200" width="200"/>
            </svg>
        </body>
    </html>
""")
Out[17]:
sat on the chair
In [18]:
HTML("""
    <html>
        <body>
            <svg width="500" height="200">
                <text x="200" y="100" font-size="30">
                    sat on the
                    <tspan dy="-20" fill = "red">
                        chair 
                    </tspan>
                     
                </text>
                <image href="cat.jpg" height="200" width="200"/>
            </svg>
        </body>
    </html>
""")
Out[18]:
sat on the chair

Write text on svg path

In [19]:
HTML("""
    <html>
        <body>
            <svg width="500" height="200">
                <path id="MyPath" fill="none" stroke="red"
                    d="M10,90 Q90,90 90,45 Q90,10 50,10 Q10,10 10,40 Q10,70 45,70 Q70,70 75,50" />
    

                <text>
                    <textPath href="#MyPath">
                        Cat sat on the chair
                    </textPath>
                </text>
                
            </svg>
        </body>
    </html>
""")
Out[19]:
Cat sat on the chair

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing