Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

subplot.rst 13 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
  1. .. index:: ! subplot
  2. .. include:: module_core_purpose.rst_
  3. *******
  4. subplot
  5. *******
  6. |subplot_purpose|
  7. The **subplot** module is used to split the current figure into a rectangular layout of subplots
  8. that each may contain a single self-contained figure. A subplot setup is started with the **begin**
  9. directive that defines the layout of the subplots, while positioning to a particular subplot for
  10. plotting is done via the **set** directive. The subplot process is completed via the **end** directive.
  11. Synopsis (begin mode)
  12. ---------------------
  13. .. include:: common_SYN_OPTs.rst_
  14. **gmt subplot begin** *nrows*\ **x**\ *ncols*
  15. |-F|\ [**f**\|\ **s**]\ *width*\ /*height*\ [**+f**\ *wfracs*\ /*hfracs*][**+c**\ *dx/dy*][**+g**\ *fill*][**+p**\ *pen*][**+w**\ *pen*]
  16. [ |-A|\ *autolabel* ]
  17. [ |-C|\ [*side*]\ *clearance* ]
  18. [ |SYN_OPT-B| ]
  19. [ |-J|\ *parameters* ]
  20. [ |-M|\ *margins* ]
  21. [ |SYN_OPT-R| ]
  22. [ |-S|\ *layout* ]
  23. [ |-T|\ *title* ]
  24. [ |SYN_OPT-V| ]
  25. [ |SYN_OPT-X| ]
  26. [ |SYN_OPT-Y| ]
  27. [ |SYN_OPT--| ]
  28. |No-spaces|
  29. Description
  30. -----------
  31. The **begin** directive of subplot defines the layout of the entire multi-panel illustration. Several
  32. options are available to specify the systematic layout, labeling, dimensions, and more for the subplots.
  33. Required Arguments
  34. ------------------
  35. *nrows*\ **x**\ *ncols*
  36. Specifies the number of rows and columns of subplots. Each row will have
  37. the same number of subplots.
  38. **Note**: You are not required to place a plot in each subplot.
  39. .. _-F:
  40. **-F**\ [**f**\|\ **s**]\ *width(s)*\ /*height(s)*\ \ [**+f**\ *wfracs*\ /*hfracs*][**+c**\ *dx/dy*][**+g**\ *fill*][**+p**\ *pen*][**+w**\ *pen*]
  41. Specify the dimensions of the figure. There are two different ways to do this:
  42. (**f**) Specify overall figure dimensions or (**s**) specify the dimensions of
  43. a single subplot.
  44. **-Ff**
  45. Specify the final **f**\ igure dimensions. The subplot dimensions are then calculated from the figure
  46. dimensions after accounting for the space that optional tick marks, annotations, labels, and margins occupy between subplots.
  47. As for other figures, annotations, ticks, and labels along the outside perimeter are not counted as part of the figure dimensions.
  48. To specify different subplot dimensions for each row (or column), append **+f** followed by a comma-separated list of width
  49. fractions, a slash, and then the list of height fractions. For example **-Ff**\ 10c/10c\ **+f**\ 3,1/1,2 will make the first column
  50. three times as wide as the second, while the second row will be twice as tall as the first row.
  51. A single number means constant widths (or heights) [Default].
  52. **-Fs**
  53. Specify the dimensions of each **s**\ ubplot directly. Then, the figure dimensions are computed from the
  54. subplot dimensions after adding the space that optional tick marks, annotations, labels, and margins occupy between subplots.
  55. As for other figures, annotations, ticks, and labels along the outside perimeter are not counted as part of the figure dimensions.
  56. To specify different subplot dimensions for each row (or column), append a comma-separated list of widths,
  57. a slash, and then the comma-separated list of heights. A single number means constant widths (or heights) [Default].
  58. For example **-Fs**\ 5c,8c/8c will make the first column 5 cm wide and the second column 8 cm wide, with
  59. all having a constant height of 8 cm. The number of values must either be one (constant across the rows or columns)
  60. or exactly match the number of rows (or columns). For geographic maps, the height of each subplot depends on
  61. your map region and projection. There are two options: (1) Specify both **-R** and **-J** and we use these
  62. to compute the height of each subplot. All subplots must share the same region and projection and you specify
  63. a zero *height*, or (2) you can select *height* based on trial and error to suit your plot layout.
  64. Optionally, you may draw the outline (**+p**\ *pen*) or paint (**+g**\ *fill*\) the figure rectangle behind the
  65. subplots, add dividing lines between panels (**+w**\ *pen*), and even expand it via **+c**. These are most
  66. useful if you supply **-B+n** to **subplot begin**, meaning no ticks or annotations will take place in the subplots.
  67. Optional Arguments
  68. ------------------
  69. .. _-A:
  70. **-A**\ [*autolabel*][**+c**\ *dx*\ [/*dy*]][**+g**\ *fill*][**+j**\|\ **J**\ *refpoint*][**+o**\ *dx*\ [/*dy*]][**+p**\ *pen*][**+r**\|\ **R**][**+v**]
  71. Specify automatic tagging of each subplot. Append either a number or letter [a].
  72. This sets the tag of the first, top-left subplot and others follow sequentially.
  73. Surround the number or letter by parentheses on any side if these should be typeset
  74. as part of the tag (**Note**: In UNIX shells you may need to escape these parentheses.)
  75. Use **+j**\|\ **J**\ *refpoint* to specify where the tag should be placed in the subplot [TL].
  76. **Note**: **+j** sets the justification of the tag to *refpoint* (suitable for interior tags)
  77. while **+J** instead selects the mirror opposite (suitable for exterior tags).
  78. Append **+c**\ *dx*\ [/*dy*] to set the clearance between the tag and a surrounding text box
  79. requested via **+g** or **+p** [3p/3p, i.e., 15% of the :term:`FONT_TAG` size dimension].
  80. Append **+g**\ *fill* to paint the tag's text box with *fill* [no painting].
  81. Append **+o**\ *dx*\ [/*dy*] to offset the tag's reference point in the direction implied
  82. by the justification [4p/4p, i.e., 20% of the :term:`FONT_TAG` size].
  83. Append **+p**\ *pen* to draw the outline of the tag's text box using selected *pen* [no outline].
  84. Append **+r** to typeset your tag numbers using lowercase Roman numerals;
  85. use **+R** for uppercase Roman numerals [Arabic numerals].
  86. Append **+v** to increase tag numbers vertically down columns [horizontally across rows].
  87. .. include:: explain_-B.rst_
  88. .. _-C:
  89. **-C**\ [*side*]\ *clearance*
  90. Reserve a space of dimension *clearance* between the margin and the subplot on the specified
  91. side, using *side* values from **w**, **e**, **s**, or **n**, or **x** for both **w** and **e**
  92. or **y** for both **s** and **n**. No *side* means all sides. The option is repeatable to set aside space
  93. on more than one side. Such space will be left untouched by the main map plotting but can
  94. be accessed by modules that plot scales, bars, text, etc. Settings specified under **begin** directive apply
  95. to all subplots, while settings under **set** only apply to the selected (active) subplot. **Note**: Common options **-X**
  96. and **-Y** are not available during subplots; use **-C** instead.
  97. .. _-J:
  98. .. |Add_-J| unicode:: 0x20 .. just an invisible code
  99. .. include:: explain_-J.rst_
  100. .. _-M:
  101. **-M**\ *margins*
  102. This is margin space that is added *between* neighboring subplots (i.e., the interior margins) *in addition*
  103. to the automatic space added for tick marks, annotations, and labels. The margins can be specified as
  104. a single value (for same margin on all sides), a pair of values separated by slashes
  105. (for setting separate horizontal and vertical margins), or the full set of four slash-separated margins
  106. (for setting separate left, right, bottom, and top margins). The actual gap created is always a sum of
  107. the margins for the two opposing sides (e.g., east plus west or south plus north margins) [Default is
  108. half the primary annotation font size, giving the full annotation font size as the default gap].
  109. .. _-R:
  110. .. |Add_-R| replace:: This is useful when all subplots share a common plot domain. In this module, the chosen region will also become the default for any data region needed by computational modules.
  111. .. include:: explain_-R.rst_
  112. .. _-S:
  113. **-S**\ *layout*
  114. Set subplot layout for shared axes. May be set separately for rows (**-SR**) and columns (**-SC**).
  115. Considerations for **-SC**: Use when all subplots in a **C**\ olumn share a common *x*-range. The first (i.e., **t**\ op) and the last
  116. (i.e., **b**\ ottom) rows will have *x* annotations; append **t** or **b** to select only one of those two rows [both].
  117. Append **+l** if annotated *x*-axes should have a label [none]; optionally append the label if it is the same
  118. for the entire subplot.
  119. Append **+t** to make space for subplot titles for each row; use **+tc** for top row titles only [no subplot titles].
  120. Labels and titles that depends on which row or column are specified as usual via a subplot's own **-B** setting.
  121. Considerations for **-SR**: Use when all subplots in a **R**\ ow share a common *y*-range. The first (i.e., **l**\ eft) and the last
  122. (i.e., **r**\ ight) columns will have *y*-annotations; append **l** or **r** to select only one of those two columns [both].
  123. Append **+l** if annotated *y*-axes will have a label [none]; optionally, append the label if it is the same
  124. for the entire subplot.
  125. Append **+p** to make all annotations axis-parallel [horizontal]; if not used you may have to set **-C** to secure
  126. extra space for long horizontal annotations.
  127. Append **+w** to draw horizontal and vertical lines between interior panels using selected pen [no lines].
  128. .. _-T:
  129. **-T**\ *heading*
  130. While individual subplots can have titles (see **-S** or **-B**), the entire figure may also have a
  131. overarching *heading* [no heading]. Font is determined by setting :term:`FONT_HEADING`.
  132. .. _-V:
  133. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  134. .. include:: explain_-V.rst_
  135. .. _-X:
  136. .. include:: explain_-XY.rst_
  137. .. include:: explain_help.rst_
  138. Synopsis (set mode)
  139. -------------------
  140. **gmt subplot set** [ *row,col*\|\ *index* ] [ **-A**\ *fixedlabel*] [ **-C**\ *side*\ *clearance* ] [ |SYN_OPT-V| ]
  141. Before you start plotting you must first select the active subplot.
  142. **Note**: If any **-J** option is passed with **?** as scale or width when plotting subplots,
  143. then the dimensions of the map are automatically determined by the subplot size and your region.
  144. For Cartesian plots: If you want the scale to apply *equally* to both dimensions
  145. then you must specify **-Jx** [The default **-JX** will fill the subplot by using unequal scales].
  146. Optional Arguments
  147. ------------------
  148. *row,col*
  149. Sets the current subplot until further notice. **Note**: First *row* or *col* is 0, not 1. If not given we go to the next subplot by order
  150. specified via **-A**. As an alternative, you may bypass the **set** mode and
  151. instead supply the common option **-c**\ [*row,col*] to the first plot command you issue in that subplot.
  152. GMT maintains information about the current figure and subplot. Also, you may give the one-dimensional
  153. *index* instead which starts at 0 and follows the row or column order set via **-A**.
  154. .. _subplot_set-A:
  155. **-A**\ *fixedlabel*
  156. Overrides the automatic labeling with the given string. No modifiers are allowed.
  157. Placement, justification, etc. are all inherited from how **-A** was specified by the
  158. initial **subplot begin** command.
  159. .. _subplot_set-C2:
  160. **-C**\ [*side*]\ *clearance*
  161. Reserve a space of dimension *clearance* between the margin and the subplot on the specified
  162. side, using *side* values from **w**, **e**, **s**, or **n**. The option is repeatable to set aside space
  163. on more than one side. Such space will be left untouched by the main map plotting but can
  164. be accessed by modules that plot scales, bars, text, etc. This setting overrides the common
  165. clearances set by **-C** during **subplot begin**.
  166. .. _subplot_set-V:
  167. .. include:: explain_-V.rst_
  168. Any number of plotting command can now take place and all output will be directed to the
  169. selected subplot. There are a few other rules that need to be followed:
  170. (1) The subplot machinery expects the first plotting command in a new subplot window
  171. to take care of plotting the base frame. The particulars of this frame may have been
  172. specified by the **-S** option in **subplot begin**. In either case, should you need to set or override
  173. frame and axis parameters then you must specify these **-B** options with this first plot
  174. command. (2) The subplot machinery automatically uses the **-X** and **-Y** options under
  175. the hood so these options are not available while a subplot is active.
  176. Synopsis (end mode)
  177. -------------------
  178. **gmt subplot end** [ |SYN_OPT-V| ]
  179. This command finalizes the current subplot, including any placement of tags, and updates the
  180. gmt.history to reflect the dimensions and linear projection required to draw the entire figure
  181. outline. This allows subsequent commands, such as colorbar, to use **-DJ** to place bars with
  182. reference to the complete figure dimensions. We also reset
  183. the current plot location to where it was prior to the subplot.
  184. Optional Arguments
  185. ------------------
  186. .. _subplot_end-V:
  187. .. include:: explain_-V.rst_
  188. Examples
  189. --------
  190. To make a minimalistic 2x2 basemap layout called panels.pdf, try::
  191. gmt begin panels pdf
  192. gmt subplot begin 2x2 -Fs8c -M5p -A -SCb -SRl -Bwstr
  193. gmt subplot set
  194. gmt basemap -R0/80/0/10
  195. gmt subplot set
  196. gmt basemap
  197. gmt subplot set
  198. gmt basemap
  199. gmt subplot set
  200. gmt basemap
  201. gmt subplot end
  202. gmt end show
  203. Restriction
  204. -----------
  205. Currently, nesting of subplots is not implemented.
  206. See Also
  207. --------
  208. :doc:`begin`,
  209. :doc:`clear`,
  210. :doc:`docs`,
  211. :doc:`end`,
  212. :doc:`figure`,
  213. :doc:`inset`,
  214. :doc:`gmt`
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...