Skip to content

Backport PR #17676 on branch v3.3.x (FIX: correctly process the tick label size) #17688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ def _get_tick_label_size(self, axis_name):
tick_kw = self._major_tick_kw
size = tick_kw.get('labelsize',
mpl.rcParams[f'{axis_name}tick.labelsize'])
return mtext.FontProperties(size).get_size_in_points()
return mtext.FontProperties(size=size).get_size_in_points()

def _copy_tick_props(self, src, dest):
"""Copy the properties from *src* tick to *dest* tick."""
Expand Down
21 changes: 18 additions & 3 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import matplotlib as mpl
from matplotlib.testing.decorators import (
image_comparison, check_figures_equal, remove_ticks_and_titles)
import matplotlib.pyplot as plt
import matplotlib.markers as mmarkers
import matplotlib.patches as mpatches
import matplotlib.colors as mcolors
import matplotlib.dates as mdates
import matplotlib.font_manager as mfont_manager
import matplotlib.markers as mmarkers
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
from numpy.testing import (
Expand Down Expand Up @@ -6322,3 +6323,17 @@ def test_autoscale_tiny_sticky():
ax.bar(0, 1e-9)
fig.canvas.draw()
assert ax.get_ylim() == (0, 1.05e-9)


@pytest.mark.parametrize('size', [size for size in mfont_manager.font_scalings
if size is not None] + [8, 10, 12])
@pytest.mark.style('default')
def test_relative_ticklabel_sizes(size):
mpl.rcParams['xtick.labelsize'] = size
mpl.rcParams['ytick.labelsize'] = size
fig, ax = plt.subplots()
fig.canvas.draw()

for name, axis in zip(['x', 'y'], [ax.xaxis, ax.yaxis]):
for tick in axis.get_major_ticks():
assert tick.label1.get_size() == axis._get_tick_label_size(name)