Hi all,
I am completing the capstone project and I have a problem, please view the image below:
For some reason, my y-tick labels are clustered.
Can someone give an idea about how to fix this, please?
Hi all,
I am completing the capstone project and I have a problem, please view the image below:
For some reason, my y-tick labels are clustered.
Can someone give an idea about how to fix this, please?
You’re setting the ytick locations to a very small range of values 0.0 : 0.2 whereas the y-axis exists over a much larger range. I don’t know what values you used for the heights but I’m assuming it’s percentage points and each percentage point is an integer. If that’s true swapping the y-ticks for integer values (5, 10, 15) etc. should work as you expect.
Otherwise you might be best using the actual y-limits which you can find with your axis reference ax
and the method- ax.get_ylim()
. A function like numpy linspace/arange
etc. is then great for creating a series of values over this range which you can then use to set your y-tick locations.
Edit: I was sure I’d come across nicer ways to do this before and after a quick search around I may no longer have the original code I used but it was based on using the following-
https://matplotlib.org/3.2.1/gallery/ticks_and_spines/tick-locators.html
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.