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

colorbar.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
  1. .. index:: ! colorbar
  2. .. include:: module_core_purpose.rst_
  3. ********
  4. colorbar
  5. ********
  6. |colorbar_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt colorbar**
  11. [ |SYN_OPT-B| ]
  12. [ |-C|\ *cpt* ]
  13. [ |-D|\ *refpoint* ]
  14. [ |-F|\ *panel* ]
  15. [ |-G|\ *zlo*\ /\ *zhi* ]
  16. [ |-I|\ [*max\_intens*\|\ *low_i*/*high_i*] ]
  17. [ |-J|\ *parameters* ]
  18. [ |-J|\ **z**\|\ **Z**\ *parameters* ]
  19. [ |-L|\ [**i**][*gap*] ]
  20. [ |-M| ]
  21. [ |-N|\ [**p**\|\ *dpi* ]]
  22. [ |-Q| ]
  23. [ |SYN_OPT-R| ]
  24. [ |-S|\ [**+a**\ *angle*][**+c**\|\ **n**\ ][**+s**][**+x**\ *label*][**+y**\ *unit*] ]
  25. [ |SYN_OPT-U| ]
  26. [ |SYN_OPT-V| ]
  27. [ |-W|\ *scale* ]
  28. [ |SYN_OPT-X| ]
  29. [ |SYN_OPT-Y| ]
  30. [ |-Z|\ *widthfile* ]
  31. [ |SYN_OPT-p| ]
  32. [ |SYN_OPT-t| ]
  33. [ |SYN_OPT--| ]
  34. .. module_common_begins
  35. Description
  36. -----------
  37. Plots gray scales or color scales on maps. Both horizontal
  38. and vertical scales are supported. For color palette tables (CPTs) with gradational
  39. colors (i.e., the lower and upper boundary of an interval have different
  40. colors) we will interpolate to give a continuous scale.
  41. Variations in intensity due to shading/illumination may be displayed by
  42. setting the option **-I**. Colors may be spaced according to a linear
  43. scale, all be equal size, or by providing a file with individual tile
  44. widths. The font used for the annotations along the scale and optional
  45. units is specified by :term:`FONT_ANNOT_PRIMARY`.
  46. If a label is requested, it is plotted with :term:`FONT_LABEL`. For
  47. a full overview of CPTs, see the Cookbook section on :ref:`Color palette tables <CPT_section>`.
  48. .. figure:: /_images/GMT_colorbar.*
  49. :width: 500 px
  50. :align: center
  51. Example of a horizontal colorbar placed below a geographic map.
  52. Required Arguments
  53. ------------------
  54. None.
  55. Optional Arguments
  56. ------------------
  57. .. _-B:
  58. **-B**\ [**p**\|\ **s**]\ *parameters*
  59. Set annotation, tick, and gridline interval for the colorbar. The
  60. x-axis label will plot beneath a horizontal bar (or vertically to
  61. the right of a vertical bar), except when using the **+m** modifier of the **-D** option. As an
  62. option, use the y-axis label to plot the data unit to the right of a
  63. horizontal bar (and above a vertical bar). If **-B** is omitted, or no annotation intervals are
  64. provided (classic mode only), the default is to annotate every color level based on the
  65. numerical entries in the CPT (which may be overridden by ULB
  66. flags in the CPT). The exception to this rule is for CPT files that were scaled to fit the range
  67. of a grid exactly and thus have arbitrary color levels; these will trigger an automatic **-Baf** setting.
  68. To specify custom text annotations for
  69. intervals, you must append ;\ *annotation* to each z-slice in the CPT. **Note**: The **-B**
  70. option relies on the **-R** and **-J** settings of the :ref:`given hierarchical level <cookbook/features:GMT Modern Mode Hierarchical Levels>`
  71. to plot correctly. For standard **-B** operations, |Add_-B_links|
  72. .. _-C:
  73. **-C**\ [*cpt*]
  74. *cpt* is the CPT to be used. If no *cpt* is appended or no **-C** is given
  75. then we use the current CPT (modern mode only). In classic mode, if no **-C**
  76. is given then we read stdin. By default all
  77. color changes are annotated. To use a subset, add an extra column to
  78. the CPT with a L, U, or B to annotate Lower, Upper, or Both
  79. color segment boundaries (but see **-B**). Like :doc:`grdview`, we can understand
  80. pattern specifications in the CPT. For CPTs where the
  81. *z* range is in meters, it may be useful to change to another unit
  82. when plotting. To do so, append **+U**\ *unit* to the file name.
  83. Likewise, if the CPT uses another unit than meter and you wish
  84. to plot the CPT versus meters, append **+u**\ *unit*.
  85. If a GMT master dynamic CPT is given instead then its *z*-range will
  86. be set to its default range (if it has one) before plotting.
  87. .. _-D:
  88. **-D**\ [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\ [**+w**\ *length*\ [/\ *width*]]\ [**+e**\ [**b**\|\ **f**][*length*]][**+h**\|\ **v**][**+j**\ *justify*]\ [**+m**\ [**a**\|\ **c**\|\ **l**\|\ **u**]][**+n**\ [*txt*]][**+o**\ *dx*\ [/*dy*]][**+r**]
  89. Defines the reference point on the map for the color scale using one of four coordinate systems:
  90. .. include:: explain_refpoint.rst_
  91. For **-Dj** or **-DJ** with codes TC, BC, ML, MR (i.e., centered on one of the map sides) we
  92. pre-calculate all further settings. Specifically, the *length* is set to 80% of the map side,
  93. horizontal or vertical depends on the side, the offset is :term:`MAP_LABEL_OFFSET` for **Dj** with an
  94. extra offset :term:`MAP_FRAME_WIDTH` for **DJ**, and annotations are placed on the side of the scale facing
  95. away from the map frame.
  96. However, you can override any of these with these modifiers:
  97. Append **+w** followed by the *length* and *width* of the color bar. If *width* is not
  98. specified then it is set to 4% of the given *length*. If *length* is not given then it defaults
  99. to 80% of the corresponding map side dimension. If either *length* or *width* end with % then
  100. those percentages are used instead to set the dimensions, where *width* is defined as a
  101. percentage of the colorbar *length*.
  102. Give a negative *length* to reverse the scale bar, or append **+r**. Append **+h** to get a
  103. horizontal scale [Default is vertical (**+v**)].
  104. By default, the anchor point on the scale is assumed to be the bottom left corner (BL), but this
  105. can be changed by appending **+j** followed by a 2-char justification code *justify* (see :doc:`text`).
  106. **Note**: If **-Dj** is used then *justify* defaults to the same as *refpoint*,
  107. if **-DJ** is used then *justify* defaults to the mirror opposite of *refpoint*. Consequently,
  108. **-DJ** is used to place a scale outside the map frame while **-Dj** is used to place it inside the frame.
  109. Add sidebar triangles for back- and/or foreground
  110. colors with **+e**. Append **f** (foreground) or **b** (background) for only one sidebar triangle [Default
  111. gives both]. Optionally, append triangle height [Default is half the barwidth].
  112. Move text to opposite side with **+m**\ [**a**\|\ **c**\|\ **l**\|\ **u**].
  113. Horizontal scale bars: Move annotations and labels above the scale bar [Default is below];
  114. the unit remains on the left.
  115. Vertical scale bars: Move annotations and labels to the left of the scale bar [Default is to the right];
  116. the unit remains below.
  117. Append one or more of **a**, **l** or **u** to control which of the annotations, label, and
  118. unit that will be moved to the opposite side. Append **c** if you want to print a
  119. vertical label as a column of characters (does not work with special characters).
  120. Append **+n** to plot a rectangle with the NaN color at
  121. the start of the bar, append *text* to change label from NaN.
  122. If not given, the default argument is JBC (Place color bar centered beneath current plot).
  123. .. _-F:
  124. **-F**\ [**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]][**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]]
  125. Without further options, draws a rectangular border around the colorbar using :term:`MAP_FRAME_PEN`. The following
  126. modifiers can be appended to |-F|, with additional explanation and examples provided in the :ref:`Background-panel`
  127. cookbook section:
  128. .. include:: explain_-F_box.rst_
  129. .. _-G:
  130. **-G**\ *zlo*\ /\ *zhi*
  131. Truncate the incoming CPT so that the lowest and highest z-levels
  132. are to *zlo* and *zhi*. If one of these equal NaN then
  133. we leave that end of the CPT alone. The truncation takes place
  134. before the plotting.
  135. .. _-I:
  136. **-I**\ [*max_intens*\|\ *low\_i*/*high_i*]
  137. Add illumination effects. Optionally, set the range of intensities
  138. from -*max\_intens* to +\ *max\_intens*. If not specified, 1 is used.
  139. Alternatively, append *low/high* intensities to specify an
  140. asymmetric range [Default is no illumination].
  141. .. |Add_-J| replace:: |Add_-J_links|
  142. .. include:: explain_-J.rst_
  143. :start-after: **Syntax**
  144. :end-before: **Description**
  145. .. _-L:
  146. **-L**\ [**i**][*gap*]
  147. Gives equal-sized color rectangles. Default scales rectangles
  148. according to the z-range in the CPT (Also see **-Z**). If
  149. *gap* is appended and the CPT is discrete we will center each
  150. annotation on each rectangle, using the lower boundary z-value for
  151. the annotation. If **i** is prepended we annotate the interval range
  152. instead. If **-I** is used then each rectangle will have its
  153. constant color modified by the specified intensity.
  154. .. _-M:
  155. **-M**
  156. Force a monochrome graybar using the (television) YIQ transformation.
  157. .. _-N:
  158. **-N**\ [**p**\|\ *dpi*]
  159. Controls how the color scale should be encoded graphically.
  160. To preferentially draw color rectangles (e.g., for discrete colors), append **p**.
  161. Otherwise we will preferentially draw images (e.g., for continuous colors).
  162. Optionally append effective dots-per-inch for rasterization of color scales [600].
  163. .. _-Q:
  164. **-Q**
  165. Select logarithmic scale and power of ten annotations. All z-values
  166. in the CPT will be converted to p = log10(z) and only integer p
  167. values will be annotated using the 10^p format [Default is linear scale].
  168. .. _-R:
  169. .. |Add_-Rgeo| unicode:: 0x20 .. just an invisible code
  170. .. include:: explain_-Rgeo.rst_
  171. .. |Add_-Rz| unicode:: 0x20 .. just an invisible code
  172. .. include:: explain_-Rz.rst_
  173. .. _-S:
  174. **-S**\ [**+a**\ *angle*][**+c**\|\ **n**\ ][**+s**][**+x**\ *label*][**+y**\ *unit*]
  175. Control various aspects of color bar appearance when **-B** is *not* used.
  176. Append **+a** to place annotations at the given *angle* [default is no slanting].
  177. Append **+c** to use custom labels if given in the CPT as annotations.
  178. Append **+n** to use numerical labels [Default].
  179. Append **+s** to skip drawing gridlines separating different color intervals [Default draws gridlines].
  180. If **-L** is used then **-B** cannot be used, hence you may optionally set a bar label via **+x**\ *label*
  181. and any unit (i.e., y-label) via **+y**\ *unit*.
  182. .. |Add_-U| replace:: |Add_-U_links|
  183. .. include:: explain_-U.rst_
  184. :start-after: **Syntax**
  185. :end-before: **Description**
  186. .. |Add_-V| replace:: |Add_-V_links|
  187. .. include:: explain_-V.rst_
  188. :start-after: **Syntax**
  189. :end-before: **Description**
  190. .. _-W:
  191. **-W**\ *scale*
  192. Multiply all *z*-values in the CPT by the provided *scale*.
  193. By default the CPT is used as is.
  194. .. |Add_-XY| replace:: |Add_-XY_links|
  195. .. include:: explain_-XY.rst_
  196. :start-after: **Syntax**
  197. :end-before: **Description**
  198. .. _-Z:
  199. **-Z**\ *widthfile*
  200. File with colorbar-width per color entry. By default, width of entry
  201. is scaled to color range, i.e., z = 0-100 gives twice the width as z
  202. = 100-150 (Also see **-L**). **Note**: The widths may be in plot distance
  203. units or given as relative fractions and will be automatically scaled
  204. so that the sum of the widths equals the requested bar length.
  205. .. |Add_perspective| replace:: (Required **-R** and **-J** for proper functioning).
  206. .. include:: explain_perspective.rst_
  207. .. include:: explain_-t.rst_
  208. .. include:: explain_help.rst_
  209. .. module_common_ends
  210. Examples
  211. --------
  212. .. include:: oneliner_info.rst_
  213. To plot a horizontal color scale (12 cm long; 0.5 cm wide) at the reference point (8,1)
  214. (paper coordinates) with justification at top center and automatic annotation interval, do
  215. ::
  216. gmt begin map
  217. gmt makecpt -T-200/1000/100 -Crainbow
  218. gmt colorbar -Dx8c/1c+w12c/0.5c+jTC+h -Bxaf+l"topography" -By+lkm
  219. gmt end show
  220. To append a vertical color scale (7.5 cm long; 1.25 cm wide) to the
  221. right of a plot that is 6 inch wide and 4 inch high, using illumination,
  222. and show back- and foreground colors, and annotating every 5 units, we
  223. provide the reference point and select the left-mid anchor point via
  224. ::
  225. gmt colorbar -Dx6.5i+jLM/2i+w7.5c/1.25c+e -Ccolors.cpt -I -Bx5+lBATHYMETRY -By+lm
  226. To overlay a horizontal color scale (4 inches long and default width) above a
  227. Mercator map produced by a previous call, ensuring a 2 cm offset from the map frame, use
  228. ::
  229. gmt colorbar -DjCT+w4i+o0/2c+h -Ccolors.cpt -Baf
  230. .. module_note_begins
  231. Notes
  232. -----
  233. #. When the CPT is discrete and no illumination is specified, the
  234. color bar will be painted using polygons. For all other cases we must
  235. paint with an image. Some color printers may give slightly different
  236. colors for the two methods given identical RGB values. See option **-N**
  237. for affecting these decisions. Also note that for years now, Apple's
  238. Preview insists on smoothing deliberately course CPT color images to a blur.
  239. Use another PDF viewer if this bothers you.
  240. #. For cyclic (wrapping) color tables the cyclic symbol is plotted to the right
  241. of the color bar. If annotations are specified there then we place the cyclic
  242. symbol at the left, unless **+n** was used in which case we center of the color bar instead.
  243. #. Discrete CPTs may have transparency applied to all or some individual slices.
  244. Continuous CPTs may have transparency applied to all slices, but not just some.
  245. .. module_note_ends
  246. See Also
  247. --------
  248. :doc:`gmt`, :doc:`makecpt`
  249. :doc:`gmtlogo`, :doc:`grd2cpt`
  250. :doc:`image`, :doc:`legend`
Tip!

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

Comments

Loading...