Skip to content

fix AxisLabel not picking up fontsize from set_ylabel in axisartist - #31155

Closed
Mr-Neutr0n wants to merge 1 commit into
matplotlib:mainfrom
Mr-Neutr0n:fix-host-subplot-ylabel-fontsize
Closed

Mr-Neutr0n wants to merge 1 commit into
matplotlib:mainfrom
Mr-Neutr0n:fix-host-subplot-ylabel-fontsize

Conversation

@Mr-Neutr0n

Copy link
Copy Markdown

Fixes #28124.

When using host_subplot (or any axisartist.Axes), calling ax.set_ylabel('text', fontsize=20) sets the fontsize on the underlying yaxis.label, but the AxisLabel in axis_artist never picks it up — it only copies the text string and color from the ref artist. So the label renders at the default size regardless of what you pass to set_ylabel.

The fix adds get_fontsize/set_fontsize overrides to AxisLabel that inherit fontsize from the ref artist by default (similar to how get_color already works via AttributeCopier). If you set fontsize directly on the AxisLabel itself, the override is respected.

from mpl_toolkits.axisartist import Axes

fig = plt.figure()
ax = fig.add_subplot(111, axes_class=Axes)
ax.set_ylabel('ylabel', fontsize=20)
# before: label renders at default size (~10pt)
# after: label renders at 20pt as expected

ax.set_ylabel('text', fontsize=20) had no effect when using
host_subplot with axisartist.Axes because AxisLabel only copied
the text string and color from the underlying axis label, but
not fontsize. Added get_fontsize/set_fontsize overrides so that
AxisLabel inherits fontsize from the ref artist by default, while
still allowing explicit overrides via label.set_fontsize().
@timhoffm

Copy link
Copy Markdown
Member

This seems AI autogenerated. The author has opened 354 PRs in 226 repositories around that time, which is not a meaningful way of contribution and implies results are most likely not sufficiently quality-checked.

Closing as this violates our AI policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: can not set ylabel fontsize in host_subplot

2 participants