|
4 | 4 |
|
5 | 5 | The :meth:`pygmt.Figure.colorbar` method creates a color scalebar. The colormap is set |
6 | 6 | via the ``cmap`` parameter. A full list of available color palette tables can be found |
7 | | -at :gmt-docs:`reference/cpts.html`. Use the ``frame`` parameter to add labels to the |
8 | | -**x** and **y** axes of the colorbar by appending **+l** followed by the desired text. |
9 | | -To add and adjust the annotations (**a**) and ticks (**f**) append the letter followed |
10 | | -by the desired interval. The placement of the colorbar is set by passing a |
11 | | -:class:`pygmt.params.Position` object to the ``position`` parameter. |
| 7 | +at :gmt-docs:`reference/cpts.html`. Use the ``label`` and ``unit`` parameters to set the |
| 8 | +labels along the long and short dimensions of the colorbar, respectively. To set the |
| 9 | +annotation and tick intervals, use the ``annot`` and ``tick`` parameters. The placement |
| 10 | +of the colorbar is set by passing a :class:`pygmt.params.Position` object to the |
| 11 | +``position`` parameter. |
12 | 12 | """ |
13 | 13 |
|
14 | 14 | # %% |
|
21 | 21 | # ============ |
22 | 22 | # Create a colorbar designed for seismic tomography - roma |
23 | 23 | # Colorbar is placed at Bottom Center (BC) by default if no position is given |
24 | | -# Add quantity and unit as labels ("+l") to the x and y axes |
25 | | -# Add annotations ("+a") in steps of 0.5 and ticks ("+f") in steps of 0.1 |
26 | | -fig.colorbar(cmap="SCM/roma", frame=["xa0.5f0.1+lVelocity", "y+lm/s"]) |
| 24 | +fig.colorbar(cmap="SCM/roma", annot=0.5, tick=0.1, label="Velocity", unit="m/s") |
27 | 25 |
|
28 | 26 | # ============ |
29 | 27 | # Create a colorbar showing the scientific rainbow - batlow |
30 | 28 | fig.colorbar( |
31 | 29 | cmap="SCM/batlow", |
32 | | - # A horizontal colorbar positioned at map coordinates (0.3, 8.7), with a |
33 | | - # length of 4 cm and a width of 0.5 cm. |
| 30 | + # A horizontal colorbar positioned at map coordinates (0.3, 8.7). |
34 | 31 | position=Position((0.3, 8.7), cstype="mapcoords"), |
35 | 32 | length=4, |
36 | 33 | width=0.5, |
37 | 34 | orientation="horizontal", |
38 | 35 | box=True, |
39 | | - frame=["x+lTemperature", "y+l°C"], |
| 36 | + label="Temperature", |
| 37 | + unit="°C", |
40 | 38 | scale=100, |
41 | 39 | ) |
42 | 40 |
|
|
45 | 43 | fig.colorbar( |
46 | 44 | cmap="SCM/oleron", |
47 | 45 | # Colorbar placed at Middle Right (MR) outside the plot bounding box, offset by 1 cm |
48 | | - # horizontally and 0 cm vertically from anchor point, with a length of 7 cm and |
49 | | - # width of 0.5 cm, and a rectangle for NaN values. |
50 | | - # Note that the label 'Elevation' is plotted vertically as a column of characters. |
| 46 | + # horizontally and 0 cm vertically from anchor point, with a rectangle for NaN |
| 47 | + # values. Note that the label 'Elevation' is plotted vertically as a column of |
| 48 | + # characters. |
51 | 49 | position=Position("MR", cstype="outside", offset=(1, 0)), |
52 | 50 | length=7, |
53 | 51 | width=0.5, |
54 | 52 | nan=True, |
55 | 53 | label_as_column=True, |
56 | | - frame=["x+lElevation", "y+lm"], |
| 54 | + label="Elevation", |
| 55 | + unit="m", |
57 | 56 | scale=10, |
58 | 57 | ) |
59 | 58 |
|
|
0 commit comments