Skip to content

[Bug]: axes.labelsize is ignored #25298

Closed

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

Activity

  1. rcomer commented on Feb 23, 2023

    @rcomer
    Member

    Thanks for the clear report @urob. I have reproduced this, and agree we seem to have broken this at v3.7.

  2. rcomer commented on Feb 23, 2023

    @rcomer
    Member

    Bisects to #21253.

  3. added this to the v3.7.1 milestone on Feb 23, 2023
  4. rcomer commented on Feb 23, 2023

    @rcomer
    Member

    But actually is already fixed by #25237.

  5. added and removed
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions