Home > Software design >  Plotting seaborn histplot bar_label with condition
Plotting seaborn histplot bar_label with condition

Time:01-12

I want to plot a enter image description here

and I want to remove all the 0 labels.

CodePudding user response:

Update

A best version suggested by @BigBen:

labels = [str(v) if v else '' for v in y.containers[0].datavalues]
y.bar_label(y.containers[0], labels=labels)

Try:

labels = []
for p in y.patches:
    h = p.get_height()
    labels.append(str(h) if h else '')

y.bar_label(y.containers[0], labels=labels)

enter image description here

  •  Tags:  
  • Related