Skip to content
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

[Bug]: can not set ylabel fontsize in host_subplot #28124

Open
BHM-Bob opened this issue Apr 23, 2024 · 1 comment
Open

[Bug]: can not set ylabel fontsize in host_subplot #28124

BHM-Bob opened this issue Apr 23, 2024 · 1 comment

Comments

@BHM-Bob
Copy link

BHM-Bob commented Apr 23, 2024

Bug summary

can not set ylabel fontsize in host_subplot with ax.set_ylabel
matplotlib==3.7.5

Code for reproduction

# normal plot
fig, ax1 = plt.subplots(figsize = (10, 8))
ax1.bar([1, 2, 3], [1, 2, 3], color = 'black')
ax1.set_ylabel('ylabel', fontsize = 20)
plt.suptitle('subplots fontsize=20', fontsize = 20)
plt.title('subplots fontsize=10', fontsize = 10)
plt.show()

# host_subplot
ax2 = host_subplot(111, axes_class=axisartist.Axes)
ax2.figure.set_size_inches((10, 8))
ax2.bar([1, 2, 3], [1, 2, 3], color = 'black')
ax2.set_ylabel('ylabel', fontsize = 20) # this code does not work
# ax2.axis['left'].label.set_fontsize(20) # this code works
plt.suptitle('host_subplot fontsize=20', fontsize = 20)
plt.title('host_subplot fontsize=10', fontsize = 10)
plt.show()

Actual outcome

ax2 has ylabel and it's font size is NOT 20 as ax1

Expected outcome

ax2 has ylabel and it's font size is 20 as ax1

Additional information

ax2.set_ylabel('ylabel', fontsize = 20) # this code does not work
# ax2.axis['left'].label.set_fontsize(20) # this code works

Operating system

windows10

Matplotlib Version

3.7.5

Matplotlib Backend

TkAgg

Python version

Python 3.8.10

Jupyter version

No response

Installation

pip

@anntzer
Copy link
Contributor

anntzer commented Apr 23, 2024

This occurs because axis_artist.AxisLabel copies (via the AttributeCopier mechanism) the text string (and the color) from the actual axis.label Text object (the "ref_artist"), but not the fontproperties. I suspect the fix involves making more properties go through AttributeCopier. (OTOH the whole thing seems a bit brittle...)

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

No branches or pull requests

2 participants