0

I have this visualization: Bar plot

And the problem is this: I need to divide y ticks into two groups to see them clearly.
I could use major and minor ticks, but then I wouldn't see all values.
I know that I can just plot it without plt.yticks(), but as I said before, all values must be on the plot.
Is it real to do such thing via build-in tool(-s)?

Roman_N
  • 183
  • 7
  • 1
    It would be helpful if you could post an example of your code, so we can give you a working example of what you want to do – Carlo Alberto May 31 '20 at 08:44
  • 1
    I am guessing you are trying to show the exact values for each bar. In that case it would be more helpful to show said values on the bars themselves, and have the y-axis show a range of values. Check this out for instructions on how to do that: https://stackoverflow.com/questions/30228069/how-to-display-the-value-of-the-bar-on-each-bar-with-pyplot-barh – Carlo Alberto May 31 '20 at 08:48

1 Answers1

1

On the Y axis leave rather default labels. Your image is clutterer partially also with Y ticks, as I suppose, copied from the source values. So it is better not to mess around with ticks (especially not the way you did it).

If you want to precisely indicate the height of each bar, use annotations. Something like:

ax = s.plot.bar(rot=0, width=0.7)
ax.set_ylim(0, s.max() * 1.15)
for p in ax.patches:
    w = p.get_height()
    ax.annotate(f'{w:.2f}', xy=(p.get_x() + p.get_width() / 2, w + 3),
        ha='center')

For the above code and data roughly similar to yours I got:

enter image description here

Valdi_Bo
  • 30,023
  • 4
  • 23
  • 41