..sumprop.., ..sumpct..count and count2d StatisticsComputed variables ..sumprop.. and ..sumpct.. take the value of the share of observations at a given location relative to the total number of observations.
This is in contrast to computed variables ..prop.. and ..proppct.. which take the value of the share of observations belonging to a given group relative to the number of observations at a given location.
import pandas as pd
from lets_plot import *
from lets_plot.mapping import as_discrete
LetsPlot.setup_html()
data = {
'x': ['a', 'a', 'a', 'a', 'b', 'b'],
'group': ['A', 'A', 'A', 'B', 'A', 'B'],
}
tooltip_options = layer_tooltips(["..sumprop..", "..sumpct..", "..prop..", "..proppct.."])
..sumprop.. and ..sumpct.. for Plots without Grouping¶Note: compare vaues shown in the tooltip.
ggplot(data, aes('x')) + \
geom_bar(tooltips=tooltip_options, labels=layer_labels().line('@..sumprop.. (@..sumpct..)'))
Note: again, compare vaues shown in the tooltip.
ggplot(data, aes('x', fill='group')) + \
geom_bar(tooltips=tooltip_options, labels=layer_labels().line('@..prop.. (@..proppct..)'))
count2d Stat Works Similarly¶df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
print(df.shape)
df.head()
ggplot(df, aes("drv", as_discrete("year"))) + \
geom_pie(aes(fill="class", size='..sum..'), tooltips=tooltip_options) + \
scale_size(guide='none')