stat_summary_bin()¶import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/iris.csv")
print(df.shape)
df.head()
geom Parameter¶ggplot(df, aes("petal_length", "sepal_length")) + \
stat_summary_bin(geom='crossbar', width=1, binwidth=.5) + \
geom_point(shape=21)
fun, fun_min, fun_max Parameters¶ggplot(df, aes("petal_length", "sepal_length")) + \
stat_summary_bin(geom='crossbar', width=1, binwidth=.5, \
fun='mq', fun_min='lq', fun_max='uq') + \
geom_point(shape=21)
quantiles Parameter¶ggplot(df, aes("petal_length", "sepal_length")) + \
stat_summary_bin(geom='crossbar', width=1, binwidth=.5, \
fun='mq', fun_min='lq', fun_max='uq', \
quantiles=[.05, .5, .95]) + \
geom_point(shape=21)
center and boundary Parameters¶def get_plot(center=None, boundary=None):
return ggplot(df, aes("petal_length", "sepal_length")) + \
stat_summary_bin(geom='crossbar', width=1, binwidth=.5, \
center=center, boundary=boundary) + \
geom_point(shape=21) + \
ggtitle("center={0}, boundary={1}".format(center, boundary))
gggrid([
get_plot(),
get_plot(center=1),
get_plot(boundary=1),
], ncol=2)
ggplot(df, aes("petal_length", "sepal_length")) + \
stat_summary_bin(aes(fill='..count..'), fun='median', \
geom='crossbar', width=1, binwidth=.5, \
fatten=5, color="white") + \
geom_point(shape=21)