数据可视化应用用Python通过ggplot2实现交互可视化(附Python应用案例)
Posted 文宇肃然
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据可视化应用用Python通过ggplot2实现交互可视化(附Python应用案例)相关的知识,希望对你有一定的参考价值。
ggplot2作图库
R语言的ggplot2绘图能力超强,python虽有matplotlib,但是语法臃肿,使用复杂,入门极难,seaborn的出现稍微改善了matplotlib代码量问题,但是定制化程度依然需要借助matplotlib,使用难度依然很大。
通过plotnine这个库,你就可以在python世界中体验下R语言的新奇感,体验可视化之美。
plotnine包,可以实现绝大多数ggplot2的绘图功能,两者语法十分相似,R和Python的语法转换成本大大降低。
-
plotnine文档 https://plotnine.readthedocs.io/en/latest/
-
R语言ggplot2文档 https://ggplot2.tidyverse.org/reference/index.html
安装
pip install plotnine
准备数据
from plotnine.data import mpg
#dataframe
mpg.head()
manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | audi | a4 | 1.8 | 1999 | 4 | auto(l5) | f |
以上是关于数据可视化应用用Python通过ggplot2实现交互可视化(附Python应用案例)的主要内容,如果未能解决你的问题,请参考以下文章