import pandas as pd
from plotnine import *
from plotnine.data import mtcars
%matplotlib inline
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)
)
参考资料:
https://plotnine.readthedocs.io/en/stable/tutorials/miscellaneous-using-letter-as-shapes.html?highlight=shape