Using letters as shapesΒΆ

[1]:
import pandas as pd

from plotnine import (
    ggplot,
    aes,
    geom_point,
    scale_shape_manual,
)
from plotnine.data import mtcars

You can create shape symbols using \(\TeX\). For example

[2]:
mixed_shapes = (
    r'$\mathrm{A}$',
    r'$\mathrm{B}$',
    r'$\mathrm{C}$',
    r'$\mathrm{D}$',
)


(ggplot(mtcars, aes('wt', 'mpg', shape='factor(gear)', colour='factor(gear)'))
 + geom_point(size=6)
 + scale_shape_manual(values=mixed_shapes)
)
../_images/tutorials_miscellaneous-using-letter-as-shapes_3_0.png
[2]:
<Figure Size: (640 x 480)>

See matplotlib documentation for more.