I have
and want the blue label to be hidden, since it’s too small and gets overlapped by the purple one.
test = (
p9.ggplot(df, p9.aes('col1', fill='col2'))
+ p9.geom_bar()
+ p9.geom_label(
p9.aes(
label=p9.after_stat(
'combine(count, count / sum(count) * 100)'
),
color='col2'
),
stat='count',
position='stack',
show_legend=False,
boxstyle='square',
boxcolor='black',
size=7
)
I tried
def combine(counts: pd.Series, percentages: pd.Series):
fmt = "{} ({}%)".format
cmax = max(counts)
return [
fmt(c, p) if c > (0.1 * cmax) else None
for c, p
in zip(counts, percentages, strict=True)
]
to no avail.
1