In [1]:
import pandas as pd

from lets_plot import *
LetsPlot.setup_html()
In [2]:
iris_df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/iris.csv")
print(iris_df.shape)
iris_df.head()
(150, 5)
Out[2]:
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
In [3]:
width, height = 400, 300
bunch = GGBunch()
bunch.add_plot(ggplot(iris_df, aes("species", "sepal_length")) + \
    geom_violin(trim=True) + \
    ggtitle("trim=True (default)"),
    0, 0, width, height)
bunch.add_plot(ggplot(iris_df, aes("species", "sepal_length")) + \
    geom_violin(trim=False, tails_cutoff=1) + \
    ggtitle("trim=False, tails_cutoff=1"),
    width, 0, width, height)
bunch.add_plot(ggplot(iris_df, aes("species", "sepal_length")) + \
    geom_violin(trim=False, tails_cutoff=2) + \
    ggtitle("trim=False, tails_cutoff=2"),
    0, height, width, height)
bunch.add_plot(ggplot(iris_df, aes("species", "sepal_length")) + \
    geom_violin(trim=False, tails_cutoff=3) + \
    ggtitle("trim=False, tails_cutoff=3 (default)"),
    width, height, width, height)
bunch.show()