|
15 | 15 | "source": [ |
16 | 16 | "Matplotlib has a `tight layout algorithm <https://matplotlib.org/3.1.1/tutorials/intermediate/tight_layout_guide.html>`__ that adjusts the space between subplots and around the figure edge to accomodate labels and plotted content.\n", |
17 | 17 | "\n", |
18 | | - "ProPlot introduces a *new* tight layout algorithm that permits *variable figure dimensions* and *variable spacing* between subplot rows and columns (see `~proplot.subplots.FlexibleGridSpec`). This allows the algorithm to preserve subplot aspect ratios, colorbar and panel widths, and optionally, subplot physical dimensions, all without producing extra whitespace." |
| 18 | + "ProPlot introduces a *new* tight layout algorithm that permits *variable figure dimensions* and *variable spacing* between subplot rows and columns (see `~proplot.subplots.FlexibleGridSpec`). This allows the algorithm to preserve subplot aspect ratios, colorbar and panel widths, and optionally, subplot physical dimensions, all without producing extra whitespace. It is applied to all figured by default -- to turn it off, pass ``tight=False`` to `~proplot.subplots.Figure` or change the :rcraw:`tight` setting." |
19 | 19 | ] |
20 | 20 | }, |
21 | 21 | { |
22 | 22 | "cell_type": "markdown", |
23 | 23 | "metadata": {}, |
24 | 24 | "source": [ |
25 | | - "## The new algorithm" |
| 25 | + "## Reference axes" |
26 | 26 | ] |
27 | 27 | }, |
28 | 28 | { |
|
31 | 31 | "raw_mimetype": "text/restructuredtext" |
32 | 32 | }, |
33 | 33 | "source": [ |
34 | | - "To fix the figure dimension(s), pass `width`, `height`, and/or `figsize` to `~proplot.subplots.subplots`. To fix the reference subplot dimension(s), use `axwidth`, `axheight`, and/or `aspect`. To set the reference subplot, use `ref` (default is ``1``, i.e. the subplot in the upper left corner). To turn off the algorithm, pass ``tight=False`` to `~proplot.subplots.Figure` or change the :rcraw:`tight` setting.\n", |
| 34 | + "To fix the figure dimension(s), pass `width`, `height`, and/or `figsize` to `~proplot.subplots.subplots`. To fix the reference subplot dimension(s), use `axwidth`, `axheight`, and/or `aspect`. To set the reference subplot, use `ref` (default is ``1``, i.e. the subplot in the upper left corner). When you specify just `width` or `axwidth`, the figure *height* is adjusted automatically to accommodate `aspect`. When you specify just `height` or `axheight`, the figure *width* is adjusted automatically.\n", |
35 | 35 | "\n", |
36 | 36 | "If the `aspect ratio mode <https://matplotlib.org/2.0.2/examples/pylab_examples/equal_aspect_ratio.html>`__ for the `ref` subplot is set to ``'equal'``, as with :ref:`Geographic and polar plots` and `~matplotlib.axes.Axes.imshow` plots, the existing aspect will be used instead of the input `aspect`.\n", |
37 | 37 | "\n", |
|
62 | 62 | "source": [ |
63 | 63 | "import proplot as plot\n", |
64 | 64 | "for ref in (3,2):\n", |
65 | | - " f, axs = plot.subplots([[1,1,2],[1,1,3],[4,5,3],[4,6,6],[7,7,8]], ref=ref, axwidth=1.1, span=False)\n", |
| 65 | + " f, axs = plot.subplots([[1,1,2],[1,1,3],[4,5,3],[4,6,6],[7,7,8]], wratios=(1.5,1,1.5), ref=ref, axwidth=1.1, span=False)\n", |
66 | 66 | " axs[ref-1].format(title='reference axes', titleweight='bold', titleloc='uc', titlecolor='red9')\n", |
67 | 67 | " axs.format(xlabel='xlabel', ylabel='ylabel', suptitle='Super title')\n", |
68 | 68 | " axs[0].format(xlabel='xlabel\\nxlabel\\nxlabel')\n", |
|
87 | 87 | "source": [ |
88 | 88 | "When you pass a spacing argument like `left`, `right`, `top`, `bottom`, `wspace`, or `hspace` to `~proplot.subplots.Figure` or `~proplot.subplots.FlexibleGridSpec`, that value is *always respected* -- the tight layout algorithm will not change it.\n", |
89 | 89 | "\n", |
90 | | - "For example, if you pass ``left='2em'`` to `~proplot.subplots.subplots`, the left margin is fixed but the right, bottom, and top margins are determined automatically. Similarly, if you pass ``wspace=('3em', None)`` and ``ncols=3`` to `~proplot.subplots.subplots`, the space between the first two columns is fixed, while the space between the second two columns is determined automatically. " |
| 90 | + "For example, if you pass ``left='2em'`` to `~proplot.subplots.subplots`, the left margin is fixed but the right, bottom, and top margins are determined automatically. Similarly, if you pass ``wspace=('3em', None)`` and ``ncols=3`` to `~proplot.subplots.subplots`, the space between the first two columns is fixed, while the space between the second two columns is determined automatically.\n", |
| 91 | + "\n", |
| 92 | + "The figure width and height are constrained similarly. If you pass both a figure `width` and `height` or a subplot `axwidth` and `axheight`, the `aspect` is ignored. If you just pass one of the `width`, `height`, `axwidth`, or `axheight`, the aspect ratio is preserved and the other dimension is adjusted accordingly." |
91 | 93 | ] |
92 | 94 | }, |
93 | 95 | { |
94 | 96 | "cell_type": "markdown", |
95 | 97 | "metadata": {}, |
96 | 98 | "source": [ |
97 | | - "## Physical units engine" |
| 99 | + "## Manual figure layout" |
98 | 100 | ] |
99 | 101 | }, |
100 | 102 | { |
|
103 | 105 | "raw_mimetype": "text/restructuredtext" |
104 | 106 | }, |
105 | 107 | "source": [ |
106 | | - "Matplotlib requires you to specify the figure size in *inches*, which must be confusing for users outside of the U.S. ProPlot supports *arbitrary physical units* for controlling the figure `width` and `height`; the reference subplot `axwidth` and `axheight`; the gridspec spacing values `left`, `right`, `bottom`, `top`, `wspace`, and `hspace`; and in a few other places.\n", |
| 108 | + "The figure layout can also be configured manually. ProPlot supports *arbitrary physical units* for controlling the figure `width` and `height`; the reference subplot `axwidth` and `axheight`; the gridspec spacing values `left`, `right`, `bottom`, `top`, `wspace`, and `hspace`; and in a few other places.\n", |
107 | 109 | "\n", |
108 | 110 | "If a sizing argument is numeric, the units are inches or points, and if string, the units are interpreted by `~proplot.utils.units`. A table of acceptable units is found in the `~proplot.utils.units` documentation. They include centimeters, millimeters, pixels, and light years (because why not?)." |
109 | 111 | ] |
|
0 commit comments