Python plotnine自定义散点画图

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

猜你喜欢

转载自blog.csdn.net/weixin_45577825/article/details/120400099