Bug summary
Axis.get_tick_space is used to determine (approximate) ticklabel size, which is then used to determine the number of ticks that can fit. Currently, this assumes that ticklabels are drawn horizontally, so rotating the tick labels can yield poor results. It would be nice if ticklabel rotation (as set by tick_params) was taken into account in the computation.
Code for reproduction
from pylab import *; rcdefaults()
fig = figure(figsize=(1.8, 1.8), layout="constrained")
ax = fig.add_subplot(xlim=(0, 1), ylim=(0, 1))
fig = figure(figsize=(1.8, 1.8), layout="constrained")
ax = fig.add_subplot(xlim=(0, 1), ylim=(0, 1))
ax.tick_params(rotation=90)
show()
Actual outcome
The first figure has reasonably spaced ticklabels; the second figure has too many yticklabels and (maybe) too few xticklabels.
Expected outcome
In the second plot ~3 yticks (at 0, 0.5, 1) and 5-6 xticks (every 0.2 or every 0.25).
Additional information
No response
Operating system
macos
Matplotlib Version
3.12.0.dev263+g0677cc8c1
Matplotlib Backend
any
Python version
Python 3.14.0
Jupyter version
ENOSUCHLIB
Installation
git checkout
Bug summary
Axis.get_tick_space is used to determine (approximate) ticklabel size, which is then used to determine the number of ticks that can fit. Currently, this assumes that ticklabels are drawn horizontally, so rotating the tick labels can yield poor results. It would be nice if ticklabel rotation (as set by tick_params) was taken into account in the computation.
Code for reproduction
Actual outcome
The first figure has reasonably spaced ticklabels; the second figure has too many yticklabels and (maybe) too few xticklabels.
Expected outcome
In the second plot ~3 yticks (at 0, 0.5, 1) and 5-6 xticks (every 0.2 or every 0.25).
Additional information
No response
Operating system
macos
Matplotlib Version
3.12.0.dev263+g0677cc8c1
Matplotlib Backend
any
Python version
Python 3.14.0
Jupyter version
ENOSUCHLIB
Installation
git checkout