Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed as not planned
Description
Bug summary
Sometimes, the axis tick labels overlaps. In such cases, manually adjusting their positions slightly is one solution. However, I found that this doesn't seem to work.
Here is a simple example. I simulated a situation where the text would overlap by setting a smaller figure size.
importmatplotlib.pyplotaspltfig=plt.figure(figsize=(0.2,0.2))ax=fig.subplots(1,1)ax.plot(range(10),range(10))plt.show()
As it can be seen, the y-axis labels '0' and '5' have some overlap.
Then, I obtained the y-axis tick label objects usingget_yticklabels
and tried to raise the position of '5' usingset_position
. As shown below, nothing changed.
Code for reproduction
importmatplotlib.pyplotaspltfig=plt.figure(figsize=(0.2,0.2))ax=fig.subplots(1,1)ax.plot(range(10),range(10))texts=ax.get_yticklabels()fortextintexts:iftext.get_text()=="5":text.set_position((0,6))plt.show()
Actual outcome
Expected outcome
The position of '5' on the y-axis should be adjusted upwards.
Additional information
No response
Operating system
Debian
Matplotlib Version
3.10.1
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.13.2
Jupyter version
4.4.0
Installation
pip