import pandas as pd
mpg = pd.read_csv("./data/mpg.csv")
mpg.head()
| mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name |
---|
0 | 18.0 | 8 | 307.0 | 130 | 3504 | 12.0 | 70 | 1 | chevrolet chevelle malibu |
---|
1 | 15.0 | 8 | 350.0 | 165 | 3693 | 11.5 | 70 | 1 | buick skylark 320 |
---|
2 | 18.0 | 8 | 318.0 | 150 | 3436 | 11.0 | 70 | 1 | plymouth satellite |
---|
3 | 16.0 | 8 | 304.0 | 150 | 3433 | 12.0 | 70 | 1 | amc rebel sst |
---|
4 | 17.0 | 8 | 302.0 | 140 | 3449 | 10.5 | 70 | 1 | ford torino |
---|
from plotnine import *
from plotnine.data import *
ggplot(data=mpg) +\
geom_point(mapping=aes(x="displ", y="hwy")) + theme_classic()
<ggplot: (324084173)>
ggplot(data=mpg) +\
geom_point(mapping=aes(x="displ", y="hwy", color="class")) + theme_classic()
<ggplot: (324192241)>
ggplot(data=mpg) +\
geom_point(mapping=aes(x="displ", y="hwy", size="class")) + theme_classic()
<ggplot: (324188691)>
# Left
ggplot(data=mpg) +\
geom_point(mapping=aes(x="displ", y="hwy", alpha="manufacturer")) + theme_classic()
<ggplot: (324284401)>
# Right
ggplot(data=mpg) +\
geom_point(mapping=aes(x="displ", y="hwy", shape="manufacturer")) + theme_classic()
<ggplot: (324342522)>
ggplot(data=mpg) +\
geom_point(mapping=aes(x="displ", y="hwy"), color="blue") + theme_classic()
<ggplot: (324407845)>
ggplot(data=mpg) +\
geom_smooth(mapping=aes(x="displ", y="hwy")) + theme_classic()
<ggplot: (324408381)>
ggplot(data=mpg) +\
geom_smooth(mapping=aes(x="displ", y="hwy", linetype="drv")) + theme_classic()
<ggplot: (324443965)>
ggplot(data=mpg) +\
geom_point(mapping=aes(x="displ", y="hwy")) +\
geom_smooth(mapping=aes(x="displ", y="hwy")) + theme_classic()
<ggplot: (324525996)>
ggplot(data=mpg, mapping=aes(x="displ", y="hwy")) +\
geom_point(mapping=aes(color="class")) +\
geom_smooth() + theme_classic()
<ggplot: (324562484)>