Plotnine: скрыть или исключить метки для небольших значений.Python

Программы на Python
Anonymous
Plotnine: скрыть или исключить метки для небольших значений.

Сообщение Anonymous »

У меня есть
Изображение

и хотим, чтобы синяя метка была скрыта, так как она слишком мала и перекрывается фиолетовой.

Код: Выделить всё

    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
)
Я попробовал

Код: Выделить всё

    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)
]
безрезультатно.


Подробнее здесь: https://stackoverflow.com/questions/790 ... all-values

Вернуться в «Python»