import numpy as np
import pandas as pd
from lets_plot import *
from lets_plot.mapping import as_discrete
LetsPlot.setup_html()
mpg = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg.head(3)
p = ggplot(mpg) + theme(axis_title_x='blank')
box_plot = (p +
geom_boxplot(aes(as_discrete('class',order=1, order_by='..middle..'), 'hwy'),
color="#579673", fill="#9AC0B3", size=1.5) +
ggsize(700, 300))
box_plot + ggtitle("Default")
box_plot + ggtitle("Flipped") + coord_flip()
bar_plot = (p +
geom_bar(aes(as_discrete('manufacturer',order_by='..count..'), fill='class', color='class'),
size=1.5, alpha=0.7, width=0.7) +
ggsize(800, 300))
bar_plot + ggtitle("Default")
bar_plot + ggtitle("Flipped") + coord_flip()