6
6
How to use constrained-layout to fit plots within your figure cleanly.
7
7
8
8
*constrained_layout* automatically adjusts subplots and decorations like
9
- legends and colorbars so that they fit in the figure window wihile still
9
+ legends and colorbars so that they fit in the figure window while still
10
10
preserving, as best they can, the logical layout requested by the user.
11
11
12
12
*constrained_layout* is similar to *tight_layout*, but uses a constraint
24
24
Simple Example
25
25
==============
26
26
27
- In matplotlib , the location of axes (including subplots) are specified in
27
+ In Matplotlib , the location of axes (including subplots) are specified in
28
28
normalized figure coordinates. It can happen that your axis labels or
29
29
titles (or sometimes even ticklabels) go outside the figure area, and are thus
30
30
clipped.
@@ -152,7 +152,7 @@ def example_plot(ax, fontsize=12, nodec=False):
152
152
# Padding and Spacing
153
153
# ===================
154
154
#
155
- # For constrained_layout, we have implimented a padding around the edge of
155
+ # For constrained_layout, we have implemented a padding around the edge of
156
156
# each axes. This padding sets the distance from the edge of the plot,
157
157
# and the minimum distance between adjacent plots. It is specified in
158
158
# inches by the keyword arguments `w_pad` and `h_pad` to the function
@@ -234,7 +234,7 @@ def example_plot(ax, fontsize=12, nodec=False):
234
234
# - `w_pad`, `h_pad` Padding around axes objects.
235
235
# Float representing inches. Default is 3./72. inches (3 pts)
236
236
# - `wspace`, `hspace` Space between subplot groups.
237
- # Float representing a fraction of the suplot widths being separated.
237
+ # Float representing a fraction of the subplot widths being separated.
238
238
# Default is 0.02.
239
239
240
240
plt .rcParams ['figure.constrained_layout.use' ] = True
@@ -472,7 +472,7 @@ def docomplicated(suptitle=None):
472
472
# https://github.com/matplotlib/matplotlib/issues.
473
473
#
474
474
# If there is a bug, please report with a self-contained example that does
475
- # not require outside data or dependencies (other than perhaps numpy).
475
+ # not require outside data or dependencies (other than numpy).
476
476
477
477
###########################################################
478
478
# Notes on the algorithm
@@ -515,7 +515,7 @@ def docomplicated(suptitle=None):
515
515
# `ax.position`, which sets where in the figure the spines are placed.
516
516
#
517
517
# Why so many stacked containers? Ideally, all that would be needed are the
518
- # Axes layotu boxes. For the Gridspec case, a container is
518
+ # Axes layout boxes. For the Gridspec case, a container is
519
519
# needed if the Gridspec is nested via `~.GridSpecFromSubplotSpec`. At the
520
520
# top level, it is desirable for symmetry, but it also makes room for
521
521
# `~.Figure.suptitle`.
@@ -529,8 +529,8 @@ def docomplicated(suptitle=None):
529
529
# ---------------------
530
530
#
531
531
# For a single Axes the layout is straight forward. The Figure and
532
- # outer Gridspec layoutboxes co-incide . The Subplotspec and Axes
533
- # boxes also co-incide because the Axes has no colorbar. Note
532
+ # outer Gridspec layoutboxes coincide . The Subplotspec and Axes
533
+ # boxes also coincide because the Axes has no colorbar. Note
534
534
# the difference between the red ``pos`` box and the green ``ax`` box
535
535
# is set by the size of the decorations around the Axes.
536
536
#
@@ -584,7 +584,7 @@ def docomplicated(suptitle=None):
584
584
#
585
585
# Adding a colorbar makes it clear why the Subplotspec layoutboxes must
586
586
# be different from the axes layoutboxes. Here we see the left-hand
587
- # subplotspec has more room to accomodate the `~.Figure.colorbar`, and
587
+ # subplotspec has more room to accommodate the `~.Figure.colorbar`, and
588
588
# that there are two green ``ax`` boxes inside the ``ss`` box.
589
589
#
590
590
# Note that the width of the ``pos`` boxes is still the same because of the
@@ -629,7 +629,7 @@ def docomplicated(suptitle=None):
629
629
# The first method is used here. The constraint that makes the heights
630
630
# be correct is in the code where ``drowsC < drows0`` which in
631
631
# this case would be 1 is less than 2. So we constrain the
632
- # the height of the 1-row Axes to be less than half the height of the
632
+ # height of the 1-row Axes to be less than half the height of the
633
633
# 2-row Axes.
634
634
#
635
635
# ..note::
@@ -650,7 +650,7 @@ def docomplicated(suptitle=None):
650
650
plot_children (fig , fig ._layoutbox , printit = False )
651
651
652
652
#######################################################################
653
- # Height and width ratios are accomodated with the same part of
653
+ # Height and width ratios are accommodated with the same part of
654
654
# the code with the smaller axes always constrained to be less in size
655
655
# than the larger.
656
656
@@ -675,7 +675,7 @@ def docomplicated(suptitle=None):
675
675
# The final piece of the code that has not been explained is what happens if
676
676
# there is an empty gridspec opening. In that case a fake invisible axes is
677
677
# added and we proceed as before. The empty gridspec has no decorations, but
678
- # the axes postion in made the same size as the occupied Axes positions.
678
+ # the axes position in made the same size as the occupied Axes positions.
679
679
#
680
680
# This is done at the start of
681
681
# `~._constrained_layout.do_constrained_layout` (``hassubplotspec``).
0 commit comments