Using letters as shapes

Using letters as shapes


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

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

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)
)

See matplotlib documentation for more.