Skip to content

constrained_layout rewrite.... #17437

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

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
704975f
FIX
jklymak May 11, 2020
8649300
Fix height/width constraints
jklymak May 12, 2020
307d9de
FIX: Better constrain CL for uneven grids
jklymak May 12, 2020
9302cce
Working sub layouts; no colorbar or suptitles
jklymak May 14, 2020
1f1d603
Close
jklymak May 15, 2020
3b247ad
Mostly working
jklymak May 16, 2020
9099649
Done?
jklymak May 16, 2020
e972198
Works?
jklymak May 17, 2020
e1688e9
FIX
jklymak May 17, 2020
06e37b7
FIXED
jklymak May 17, 2020
1fe573d
ADD
jklymak May 17, 2020
7ed3b68
ADD
jklymak May 17, 2020
637bbb1
ADD
jklymak May 17, 2020
d5fe4cc
FIX: fix aspect ratio in subpanel
jklymak May 19, 2020
cf4139f
FIX: fix bbox of subpanel
jklymak May 19, 2020
be5349a
fix import
jklymak May 20, 2020
5c2d62b
Remove margin_min
jklymak May 20, 2020
fe3bbe0
DOC: add docs for layoutgrid
jklymak May 20, 2020
287507d
FLK8
jklymak May 20, 2020
62b6542
DOC
jklymak May 20, 2020
add42f4
DOC: more documentation
jklymak May 20, 2020
f90da3c
Flake8
jklymak May 20, 2020
c3777c2
FLK8
jklymak May 20, 2020
09c2e29
FLK8
jklymak May 20, 2020
dfdb7bc
FLK8
jklymak May 20, 2020
7442fbb
DOC
jklymak May 20, 2020
272349c
Almost
jklymak May 21, 2020
87babff
Fixed
jklymak May 21, 2020
f7b073e
DOC: inhereted members
jklymak May 21, 2020
0ff7270
Rebase
jklymak May 21, 2020
1d47d88
Flake8
jklymak May 21, 2020
0d94896
TST: fix some CL images
jklymak May 21, 2020
3c005c1
DOC: clean up references
jklymak May 22, 2020
bfd2b6e
DOC: more doc
jklymak May 22, 2020
e615134
DOC: more doc
jklymak May 22, 2020
880aa10
DOC: try and get crossrefs
jklymak May 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/figure_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Classes
:toctree: _as_gen/
:template: autosummary.rst
:nosignatures:
:inhereted-members:

AxesStack
SubPanel
Figure
SubplotParams

Expand Down
2 changes: 1 addition & 1 deletion doc/users/prev_whats_new/whats_new_3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ to a figure. E.g. ::
fig.add_artist(circ)

In case the added artist has no transform set previously, it will be set to
the figure transform (``fig.transFigure``).
the figure transform (``fig.transPanel``).
This new method may be useful for adding artists to figures without axes or to
easily position static elements in figure coordinates.

Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid1/inset_locator_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
# Create an inset horizontally centered in figure coordinates and vertically
# bound to line up with the axes.
from matplotlib.transforms import blended_transform_factory
transform = blended_transform_factory(fig.transFigure, ax2.transAxes)
transform = blended_transform_factory(fig.transPanel, ax2.transAxes)
axins4 = inset_axes(ax2, width="16%", height="34%",
bbox_to_anchor=(0, 0, 1, 1),
bbox_transform=transform, loc=8, borderpad=0)
Expand Down
2 changes: 1 addition & 1 deletion examples/pyplots/auto_subplots_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def on_draw(event):
bbox = label.get_window_extent()
# the figure transform goes from relative coords->pixels and we
# want the inverse of that
bboxi = bbox.transformed(fig.transFigure.inverted())
bboxi = bbox.transformed(fig.transPanel.inverted())
bboxes.append(bboxi)
# the bbox that bounds all the bboxes, again in relative figure coords
bbox = mtransforms.Bbox.union(bboxes)
Expand Down
1 change: 0 additions & 1 deletion examples/subplots_axes_and_figures/gridspec_nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def format_axes(fig):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
ax.tick_params(labelbottom=False, labelleft=False)


# gridspec inside gridspec
fig = plt.figure()

Expand Down
48 changes: 48 additions & 0 deletions examples/subplots_axes_and_figures/subpanels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
================
Nested Subpanels
================

Sometimes it is desirable to have a figure that has two different
layouts in it. This can be achieved with
:doc:`nested gridspecs</gallery/subplots_axes_and_figures/gridspec_nested>`
but having a virtual figure with its own artists is helpful, so
Matplotlib also has "subpanels", usually implimented by calling
``.figure.PanelBase.add_subpanel`` in a way that is analagous to
``.figure.PanelBase.add_subplot``.

"""
import matplotlib.pyplot as plt
import numpy as np

def example_plot(ax, fontsize=12, hide_labels=False):
ax.pcolormesh(np.random.randn(30, 30))
if not hide_labels:
ax.set_xlabel('x-label', fontsize=fontsize)
ax.set_ylabel('y-label', fontsize=fontsize)
ax.set_title('Title', fontsize=fontsize)


# gridspec inside gridspec
fig = plt.figure(constrained_layout=True)
subpanels = fig.subpanels(1, 2, wspace=0.07)

axsLeft = subpanels[0].subplots(1, 2, sharey=True)
subpanels[0].set_facecolor('0.75')
for ax in axsLeft:
example_plot(ax)
subpanels[0].suptitle('Left plots', fontsize='x-large')

axsRight = subpanels[1].subplots(3, 1, sharex=True)
for nn, ax in enumerate(axsRight):
example_plot(ax, hide_labels=True)
if nn == 2:
ax.set_xlabel('xlabel')
if nn == 1:
ax.set_ylabel('ylabel')
subpanels[1].suptitle('Right plots', fontsize='x-large')

fig.suptitle('Figure suptitle', fontsize='xx-large')

plt.show()

2 changes: 1 addition & 1 deletion examples/subplots_axes_and_figures/subplots_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
# Still there remains an unused empty space between the subplots.
#
# To precisely control the positioning of the subplots, one can explicitly
# create a `.GridSpec` with `.add_gridspec`, and then call its
# create a `.GridSpec` with `~.Figure.add_gridspec`, and then call its
# `~.GridSpecBase.subplots` method. For example, we can reduce the height
# between vertical subplots using ``add_gridspec(hspace=0)``.
#
Expand Down
Loading