|
199 | 199 | # the first subplot occupying the first row.
|
200 | 200 |
|
201 | 201 | fig = pygmt.Figure()
|
202 |
| -with fig.subplot(nrows=2, ncols=2, figsize=("15c", "6c"), autolabel=True): |
| 202 | +# Bottom row, two subplots |
| 203 | +with fig.subplot(nrows=1, ncols=2, figsize=("15c", "3c"), autolabel="b)"): |
203 | 204 | fig.basemap(
|
204 |
| - region=[0, 10, 0, 10], projection="X15c/3c", frame=["af", "WSne"], panel=[0, 0] |
| 205 | + region=[0, 5, 0, 5], projection="X?", frame=["af", "WSne"], panel=[0, 0] |
205 | 206 | )
|
206 |
| - fig.text(text="TEXT", x=5, y=5, projection="X15c/3c") |
207 | 207 | fig.basemap(
|
208 |
| - region=[0, 5, 0, 5], projection="X?", frame=["af", "WSne"], panel=[1, 0] |
| 208 | + region=[0, 5, 0, 5], projection="X?", frame=["af", "WSne"], panel=[0, 1] |
209 | 209 | )
|
| 210 | +# Top row, one subplot |
| 211 | +with fig.subplot( |
| 212 | + nrows=1, ncols=1, figsize=("15c", "3c"), autolabel="a)", yshift="h+1c" |
| 213 | +): |
210 | 214 | fig.basemap(
|
211 |
| - region=[0, 5, 0, 5], projection="X?", frame=["af", "WSne"], panel=[1, 1] |
| 215 | + region=[0, 10, 0, 10], projection="X?", frame=["af", "WSne"], panel=[0, 0] |
212 | 216 | )
|
213 |
| -fig.show() |
| 217 | + fig.text(text="TEXT", x=5, y=5) |
214 | 218 |
|
215 |
| -############################################################################### |
216 |
| -# |
217 |
| -# When drawing the three basemaps, the last two basemaps use |
218 |
| -# ``projection="X?"``, so GMT will automatically determine the size of the |
219 |
| -# subplot according to the size of the subplot area. In order for the first |
220 |
| -# subplot to fill up the entire top row space, we use manually adjusted the |
221 |
| -# subplot width to 15cm using ``projection="X15c/3c"``. |
| 219 | +fig.show() |
222 | 220 |
|
223 | 221 | ###############################################################################
|
224 |
| -# .. note:: |
225 |
| -# |
226 |
| -# There are bugs that have not been fixed in the above example. |
227 |
| -# |
228 |
| -# In subplot mode, the size of each subgraph is controlled by the |
229 |
| -# ``figsize`` option of :meth:`pygmt.Figure.subplot`. Users can override |
230 |
| -# this and use ``projection`` to specify the size of an individual subplot, |
231 |
| -# but this size will not be remembered. If the next command does not |
232 |
| -# specify ``projection``, the default size of the subplot mode will be |
233 |
| -# used, and the resulting plot will be inccorect. |
234 | 222 | #
|
235 |
| -# The current workaround is to use the same ``projection`` option in all |
236 |
| -# commands for the subplot. For example, we forced subplot (a) to have a |
237 |
| -# different size using ``projection="15c/3c``. The next command within the |
238 |
| -# subplot (e.g. ``text``) must also use ``projection="x15c/3c"``, otherwise |
239 |
| -# the placement will be wrong. |
| 223 | +# We start by drawing the bottom two subplots, setting ``autolabel="b)"`` so |
| 224 | +# that the subplots are labelled 'b)' and 'c)'. Then, we plot a single subplot |
| 225 | +# on the top row by using ``fig.subplot(..., yshift="h+1c")`` which shifts the |
| 226 | +# plot origin 1 cm beyond the **h**\ eight of the previous (bottom row) plot. |
| 227 | +# You may need to adjust this ``yshift`` parameter to make your plot look nice. |
| 228 | +# This top row uses ``autolabel="a)"``, and we also plotted some text inside. |
| 229 | +# Note that ``projection="X?"`` was used to let GMT automatically determine the |
| 230 | +# size of the subplot according to the size of the subplot area. |
240 | 231 |
|
241 | 232 | ###############################################################################
|
242 |
| -# Since we skipped the second subplot, the auto label function will name the |
243 |
| -# three subplots as a, c and d, which is not what we want, so we have to use |
244 |
| -# ``fig.set_panel(..., fixedlabel="(a)")`` to manually set the subplot label. |
| 233 | +# You can also manually override the ``autolabel`` for each subplot using for |
| 234 | +# example, ``fig.set_panel(..., fixedlabel="b) Panel 2"`` which would allow you |
| 235 | +# to manually label a single subplot as you wish. This can be useful for adding |
| 236 | +# a more descriptive subtitle to individual subplots. |
0 commit comments