proplot-dev / proplot

🎨 A succinct matplotlib wrapper for making beautiful, publication-quality graphics
https://proplot.readthedocs.io
MIT License
1.11k stars 102 forks source link

incorrect position of ylabel #373

Closed Yefee closed 2 years ago

Yefee commented 2 years ago

Description

When having 2 axes, the ylabel of top panel appears in the middle of the left figure.

Steps to reproduce

hydl = np.sin(2*np.arange(0, 60, 0.1))
vwsdl = np.cos(2*np.arange(0, 60, 0.1))

fig, axs = pplt.subplots(ncols=1, nrows=2)
axs[0].plot(hydl)
axs[1].plot(vwsdl)
axs[0].format(title='AA', titleweight='bold', ylabel='CC')
axs[1].format(title='BB', titleweight='bold', ylabel='DD')

Expected behavior: CC appears at the left of top panel DDappears at the left of bottom panel

Actual behavior: CC appears in the middle

image

Equivalent steps in matplotlib

Please try to make sure this bug is related to a proplot-specific feature. If you're not sure, try to replicate it with the native matplotlib API. Matplotlib bugs belong on the matplotlib github page.

# your code here, if applicable
import matplotlib.pyplot as plt
fig, axs = plt.subplots(ncols=1, nrows=2)
axs[0].plot(hydl)
axs[0].set_ylim([-1.6, 1.6])
axs[1].plot(vwsdl)
axs[1].set_ylim([-2, 2])
axs[0].set_ylabel('CC')
axs[1].set_ylabel('DD')
image

Proplot version

import matplotlib; print(matplotlib.version); import proplot; print(proplot.version) 3.4.3 0.9.5

syrte commented 2 years ago

This is actually the behavior expected from the proplot side, though I agree that it is a bit counter-intuitive. When initializing the figure, you may add "sharey=False" to disable the label sharing:

fig, axs = pplt.subplots(ncols=1, nrows=2, sharey=False)

It should fix your problem.

Yefee commented 2 years ago

Good to know! Thanks!

lukelbd commented 1 year ago

Thanks for the help @syrte. You're right this is counterintuitive -- I'll consider disabling share and span in the next version by default... or maybe even try to automatically detect whether users want shared labels depending on whether they separately apply labels to individual axes (as in your example) or make single axs.format(xlabel='label') calls.

See #384 for updates