0

I wrote this code and I want to add values above (if the value is >0) and below (if the value is <0). However, I only managed to put the values above the bars. Can someone help me here putting the <0 values below the bar?

ax.1+plt.bar(r, elements,color=bar_colors,edgecolor='none',width=bardWidth)
ax=dataset.plot(width=5.0,kind='bar',y=dataset.columns,figsize=(6,5),zorder=3)

for p in ax.patches:
  ax.annotate("%.2f"%p.get.height(),(p.get_x()+p.get.width()/2.,p.get_height()),ha='center',va='center',xytext=(0,10),textcoords='offsetpoints')
  • Does this get you anywhere? https://stackoverflow.com/questions/19917587/matplotlib-advanced-bar-plot/19919397#19919397 – Paul H Dec 08 '20 at 16:07
  • Thanks for your help but I also want to put the values below the bars if they are negative. – Squirrel15 Dec 08 '20 at 16:12
  • 1
    you'll need to modify that logic then. Some of the labels in the example are above, some are below. it can be easily adapted to your situation – Paul H Dec 08 '20 at 16:24

0 Answers0