0

Seaborn Image

I do not want to see the 0s being displayed in the countplot. Is there a way to eliminate showing just 0s from the labels on the graph?

ax = sbn.countplot(data=df,x='link',hue='Status', width=0.2)

for container in ax.containers:
  ax.bar_label(container,)
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
saas
  • 15
  • 1
  • 5
  • is "filtering your data so you don't even _have_ zeroes to show" an option? – Mike 'Pomax' Kamermans Jun 21 '23 at 22:56
  • 1
    `ax.bar_label(container, fmt=lambda x: x if x > 0 else '')` with matplotlib 3.7.1, or `labels = [v.get_height() if v.get_height() > 0 else '' for v in c]` and `ax.bar_label(c, labels=labels, label_type='center')` – Trenton McKinney Jun 22 '23 at 03:45
  • 1
    Thank you Trenton. The following code worked. ax.bar_label(container, fmt=lambda x: x if x > 0 else '') – saas Jun 22 '23 at 21:15

0 Answers0