-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Closed
Copy link
Labels
Good first issueOpen a pull request against these issues if there are no active ones!Open a pull request against these issues if there are no active ones!topic: geometry managerLayoutEngine, Constrained layout, Tight layoutLayoutEngine, Constrained layout, Tight layouttopic: testing
Milestone
Description
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
import numpy as np
import matplotlib.pyplot as plt
data = [0,1]
fig, (ax3, ax1, ax2) = plt.subplots(3, 1, constrained_layout=True, figsize=(6.4,8),
gridspec_kw={"height_ratios":(1, 1, .7)})
ax1.plot(data, data)
ax1.set_ylabel("Label")
ax2.plot(data, data)
ax2.set_ylim(-1.5, 1.5)
ax2.set_ylabel("Label")
ax3.plot(data, data)
ax3.set_ylabel("Label")
fig.align_ylabels(axs=(ax3, ax1, ax2))
fig.savefig("test.pdf")
In savefig
, backend="PDF"
and backend="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
- Operating system: Windows 10 2004 Build 19041.685
- Matplotlib version: 3.3.3
- Matplotlib backend (
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inline - Python version: 3.7.3
- Jupyter version (if applicable):
- jupyter core : 4.6.3
- jupyter-notebook : 6.1.1
- qtconsole : 4.7.5
- ipython : 7.17.0
- ipykernel : 5.3.4
- jupyter client : 6.1.6
- jupyter lab : 2.2.4
- nbconvert : 5.6.1
- ipywidgets : 7.5.1
- nbformat : 5.0.7
- traitlets : 4.3.3
- Other libraries:
Matplotlib 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
Metadata
Metadata
Assignees
Labels
Good first issueOpen a pull request against these issues if there are no active ones!Open a pull request against these issues if there are no active ones!topic: geometry managerLayoutEngine, Constrained layout, Tight layoutLayoutEngine, Constrained layout, Tight layouttopic: testing