import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv")
print(df.shape)
df.head()
(234, 12)
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 |
2 | 3 | audi | a4 | 2.0 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact |
3 | 4 | audi | a4 | 2.0 | 2008 | 4 | auto(av) | f | 21 | 30 | p | compact |
4 | 5 | audi | a4 | 2.8 | 1999 | 6 | auto(l5) | f | 16 | 26 | p | compact |
def get_plot(specs):
return ggplot(df, aes("cty", "hwy", color="drv")) + \
geom_point() + \
specs + \
theme(axis_title='blank', legend_position='none')
gggrid([
get_plot(ggtitle("minimal2 (default)")),
get_plot(theme_bw() + ggtitle("bw")),
get_plot(theme_grey() + ggtitle("grey")),
get_plot(theme_classic() + ggtitle("classic")),
get_plot(theme_light() + ggtitle("light")),
get_plot(theme_minimal() + ggtitle("minimal")),
], ncol=2)