-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Automatically Aligned Labels outside Figure with Constrained Layout in Exported File #19152
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
Comments
Thanks for the bug report. This (coincidentally) appears to have been fixed by #17494 and will be in the 3.4 release, so I don't think there is an action item here, except perhaps to add a test for this? I'll add a "Good first issue" here in case someone wants to add a test. Probably can be done w/o an image comparison, but I'd have to play with it to be sure. |
changing to |
Yes, changing to |
I'm brand new to open source — if I were looking to write a test, what files should I look at? Thank you! |
@Hathaway2010 Please have a look at https://matplotlib.org/devel/index.html and https://github.com/matplotlib/matplotlib/tree/master/lib/matplotlib/tests I think maybe |
Thank you! I'll see if I can do something in the next few days! |
Hi! I'm pretty sure I've found a test that does the trick: after saving the pdf in the code for reproduction, I do
When I use an old version of matplotlib, this detects that the top two labels are 1) not aligned with the third (i.e., the three aren't approximately equal) and 2) have gone off the page (have an x0 greater than 1). When running pytest on my branch of the current repository, everything seems to be fine — the test passes, and the saved PDF looks fine. I have two beginner's questions:
Many thanks, and sorry for my ignorance. |
Hey, I think your code example has lost some linebreaks. If you want line breaks in code, use a Fenced Code Block with three backticks or tildes. Example:
renders as
|
fixed, thank you! |
Does this need to be saved as pdf? Or do you just need to trigger a draw via Yes, it seems |
|
Closed by #19373 |
Bug report
Bug summary
When using constrained layout on a specific 3-plot layout with automatically aligned labels, the exported plot has labels outside the page. The image in Jupyter Lab renders fine.
Code for reproduction
In
savefig
,backend="PDF"
andbackend="PGF"
or exporting as .png leads to the same, unexpected outcome for me.Actual outcome
Exported PDF Screenshot:
Expected outcome
Screenshot from Jupyter Notebook:
Matplotlib version
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineMatplotlib installed via pip. Python installed via Windows installer from python.org.
Workaround
Use manual label positions as explained in https://matplotlib.org/gallery/pyplots/align_ylabels.html
The text was updated successfully, but these errors were encountered: