Skip to content

[Bug]: axes.labelsize is ignored #25298

@urob

Description

@urob

y### Bug summary

In Matplotlib Version 3.7.0, setting axes.labelsize via a mplstyle file or by updating rcParams does not change the font size of xlabel and ylabel.

Code for reproduction

import matplotlib.pyplot as plt

size = 24
plt.style.use("default")
plt.rcParams.update(
    {
        "axes.labelsize": size,  # has no effect
        "axes.titlesize": size,  # works as expected
        "xtick.labelsize": size,  # works as expected
        "ytick.labelsize": size,  # works as expected
    }
)

fig, ax = plt.subplots(constrained_layout=True)
ax.plot([0, 1], [0, 1])
ax.set(title="Title", xlabel="x-label", ylabel="y-label")
plt.show()

Actual outcome

image

Expected outcome

I would expect the xlabel and ylabel to have font size 24 (same as the tick-labels and the title).

Additional information

The issue seems to only occur in Matplotlib Version 3.7.0 (installed from conda-forge). When downgrading to Version 3.6.2, everything works expected. Here is a minimal conda-environment to reproduce the issue:

# env.yml -- install via "conda env create -f env.yml"
name: minimal_example
channels:
  - conda-forge
dependencies:
  - python=3.10
  # - matplotlib=3.6.2  # works
  - matplotlib=3.7.0  # does not work

In either case, setting the xlabel size directly via plt.xlabel("x-label", size=24) or via ax.set_xlabel("x-label", size=24) works as expected.

Operating system

Windows 11

Matplotlib Version

3.7.0

Matplotlib Backend

module://backend_interagg

Python version

3.10.9

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions