Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Completely disable passing of gridspec_kw to inner layouts
  • Loading branch information
joshbarrass committed Oct 17, 2022
commit 36d18ab33b57dc5b64c314102aa37b4c9d34d2b2
17 changes: 9 additions & 8 deletions doc/api/next_api_changes/behavior/24189-JB.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
``fig.subplot_mosaic`` no longer passes the ``width_ratios`` or ``height_ratios`` args to the nested gridspecs.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``fig.subplot_mosaic`` no longer passes the ``gridspec_kw`` args to the nested gridspecs.
Comment thread
joshbarrass marked this conversation as resolved.
Outdated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, the entirety of the ``gridspec_kw`` dictionary was passed
to the nested gridspecs. This caused an error if the inner layout was
incompatible with one of these ratios. A new dictionary is now made,
``nested_gs_kw``, where the ``"width_ratios"`` and ``"height_ratios"``
keys have been removed, which is passed to any nested gridspecs. This
prevents such errors.
Previously, the ``gridspec_kw`` dictionary was passed to the nested
gridspecs, as well as the outer gridspec. This caused errors with many
options, such as the ``"width_ratios"`` and ``"height_ratios"``
options if the inner layout was incompatible with either of these
ratios. This dictionary is no longer passed to the inner layouts, and
users are directed by the docstring to construct the layout manually
if the inner layouts require any of these args.
Comment thread
joshbarrass marked this conversation as resolved.
Outdated
9 changes: 5 additions & 4 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1856,9 +1856,10 @@ def subplot_mosaic(self, mosaic, *, sharex=False, sharey=False,

gridspec_kw : dict, optional
Dictionary with keywords passed to the `.GridSpec` constructor used
to create the grid the subplots are placed on. The 'width_ratios'
and 'height_ratios' keys, if present, will be removed from this
dictionary before it is passed to any inner layouts.
to create the grid the subplots are placed on. This argument
applies only to the outer layout and will not be passed to the
inner layouts. For more complex layouts, one should use
`.subfigure` and `.subplots` directly.
Comment thread
joshbarrass marked this conversation as resolved.
Outdated

empty_sentinel : object, optional
Entry in the layout to mean "leave this space empty". Defaults
Expand Down Expand Up @@ -2035,7 +2036,7 @@ def _do_layout(gs, mosaic, unique_ids, nested):
# recursively add the nested mosaic
rows, cols = nested_mosaic.shape
nested_output = _do_layout(
gs[j, k].subgridspec(rows, cols, **nested_gs_kw),
gs[j, k].subgridspec(rows, cols),
nested_mosaic,
*_identify_keys_and_nested(nested_mosaic)
)
Expand Down