plotnine
优快云的编辑和上传图片体验太差,更多的例子到plot-example里去看。
https://github.com/has2k1/plotnine-examples
安装
- 官网:https://plotnine.readthedocs.io/en/stable/index.html
- github:https://github.com/has2k1/plotnine
- ggplot2官网:http://ggplot2.tidyverse.org/reference/index.html#section-plot-basics
conda install -c conda-forge plotnine
import pandas as pd
import numpy as np
from plotnine import *
from plotnine.data import *
mpg.head(2)
Unnamed: 0 | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | audi | a4 | 1.8 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact |
1 | 2 | audi | a4 | 1.8 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact |
基础图形
参考R for Data Science:http://r4ds.had.co.nz/data-visualisation.html 中的Data visualisation
散点图
# R 写法
# (ggplot(data = mpg) +
# geom_point(mapping = aes(x = di