In [1]:
import pandas as pd
from lets_plot import *

LetsPlot.setup_html()
In [2]:
mpg_df = pd.read_csv ("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg_df
Out[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
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
... ... ... ... ... ... ... ... ... ... ... ... ...
229 230 volkswagen passat 2.0 2008 4 auto(s6) f 19 28 p midsize
230 231 volkswagen passat 2.0 2008 4 manual(m6) f 21 29 p midsize
231 232 volkswagen passat 2.8 1999 6 auto(l5) f 16 26 p midsize
232 233 volkswagen passat 2.8 1999 6 manual(m5) f 18 26 p midsize
233 234 volkswagen passat 3.6 2008 6 auto(s6) f 17 26 p midsize

234 rows × 12 columns

In [3]:
p = ggplot(mpg_df, aes("cty","hwy", color='drv')) + \
    geom_point(tooltips=layer_tooltips().line('@manufacturer @model'))
In [4]:
p2 = p + facet_grid(y="drv")
In [5]:
w, h = 600, 400

def themeWithFlavor(plot, theme, title):
    bunch = GGBunch()
    bunch.add_plot(plot + theme + ggtitle(title), 0, 0, w, h) 
    bunch.add_plot(plot + theme + flavor_darcula()+ ggtitle("darcula"), w, 0, w, h) 
    bunch.add_plot(plot + theme + flavor_solarized_light()+ ggtitle("solarized_light"), 0, h, w, h) 
    bunch.add_plot(plot + theme + flavor_solarized_dark()+ ggtitle("solarized_dark"), w, h, w, h) 
    bunch.add_plot(plot + theme + flavor_high_contrast_light()+ ggtitle("high_contrast_light"), 0, h*2, w, h) 
    bunch.add_plot(plot + theme + flavor_high_contrast_dark()+ ggtitle("high_contrast_dark"), w, h*2, w, h) 
    bunch.show()
In [6]:
themeWithFlavor(p, theme_minimal2(), "minimal2")
In [7]:
themeWithFlavor(p2, theme_minimal2(), "minimal2 + facet_grid")
In [8]:
themeWithFlavor(p, theme_minimal(), "minimal")
In [9]:
themeWithFlavor(p2, theme_minimal(), "minimal + facet_grid")
In [10]:
themeWithFlavor(p, theme_classic(), "classic")
In [11]:
themeWithFlavor(p2, theme_classic(), "classic + facet_grid")
In [12]:
themeWithFlavor(p, theme_light(), "light")
In [13]:
themeWithFlavor(p2, theme_light(), "light + facet_grid")
In [14]:
themeWithFlavor(p, theme_grey(), "grey")
In [15]:
themeWithFlavor(p2, theme_grey(), "grey + facet_grid")
In [16]:
themeWithFlavor(p, theme_none(), "none")
In [17]:
themeWithFlavor(p2, theme_none(), "none + facet_grid")
In [18]:
themeWithFlavor(p, theme_bw(), "bw")
In [19]:
themeWithFlavor(p2, theme_bw(), "bw + facet_grid")