|
2 | 2 | Configuring PyGMT defaults
|
3 | 3 | ==========================
|
4 | 4 |
|
5 |
| -Default GMT parameters can be set globally or locally using |
6 |
| -:class:`pygmt.config`. |
| 5 | +Default GMT parameters can be set globally or locally using :class:`pygmt.config`. |
7 | 6 | """
|
8 | 7 |
|
9 | 8 | # %%
|
|
13 | 12 | # Configuring default GMT parameters
|
14 | 13 | # ----------------------------------
|
15 | 14 | #
|
16 |
| -# Users can override default parameters either temporarily (locally) or |
17 |
| -# permanently (globally) using :class:`pygmt.config`. The full list of default |
18 |
| -# parameters that can be changed can be found at :gmt-docs:`gmt.conf.html`. |
| 15 | +# Users can override default parameters either temporarily (locally) or permanently |
| 16 | +# (globally) using :class:`pygmt.config`. The full list of default parameters that can |
| 17 | +# be changed can be found at :gmt-docs:`gmt.conf.html`. |
19 | 18 | #
|
20 | 19 | # We demonstrate the usage of :class:`pygmt.config` by configuring a map plot.
|
21 | 20 |
|
|
31 | 30 | # Globally overriding defaults
|
32 | 31 | # ----------------------------
|
33 | 32 | #
|
34 |
| -# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of |
35 |
| -# which there are 5 options: ``fancy`` (default, see above), ``fancy+``, |
36 |
| -# ``plain``, ``graph`` (which does not apply to geographical maps) and |
37 |
| -# ``inside``. |
| 33 | +# The ``MAP_FRAME_TYPE`` parameter specifies the style of map frame to use, of which |
| 34 | +# there are 5 options: ``fancy`` (default, see above), ``fancy+``, ``plain``, ``graph`` |
| 35 | +# (which does not apply to geographical maps) and ``inside``. |
38 | 36 | #
|
39 |
| -# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick |
40 |
| -# annotations. The default uses degrees and minutes. Here we specify the ticks |
41 |
| -# to be a decimal number of degrees. |
| 37 | +# The ``FORMAT_GEO_MAP`` parameter controls the format of geographical tick annotations. |
| 38 | +# The default uses degrees and minutes. Here we specify the ticks to be a decimal number |
| 39 | +# of degrees. |
42 | 40 |
|
43 | 41 | fig = pygmt.Figure()
|
44 | 42 |
|
45 |
| -# Configuration for the 'current figure'. |
| 43 | +# Configuration for the 'current figure' |
46 | 44 | pygmt.config(MAP_FRAME_TYPE="plain")
|
47 | 45 | pygmt.config(FORMAT_GEO_MAP="ddd.xx")
|
48 | 46 |
|
|
56 | 54 | # Locally overriding defaults
|
57 | 55 | # ---------------------------
|
58 | 56 | #
|
59 |
| -# It is also possible to temporarily override the default parameters, which is |
60 |
| -# very useful for limiting the scope of changes to a particular plot. |
61 |
| -# :class:`pygmt.config` is implemented as a context manager, which handles the |
62 |
| -# setup and teardown of a GMT session. Python users are likely familiar with |
63 |
| -# the ``with open(...) as file:`` snippet, which returns a ``file`` context |
64 |
| -# manager. In this way, it can be used to override a parameter for a single |
65 |
| -# command, or a sequence of commands. An application of :class:`pygmt.config` |
66 |
| -# as a context manager is shown below: |
| 57 | +# It is also possible to temporarily override the default parameters, which is very |
| 58 | +# useful for limiting the scope of changes to a particular plot. :class:`pygmt.config` |
| 59 | +# is implemented as a context manager, which handles the setup and teardown of a GMT |
| 60 | +# session. Python users are likely familiar with the ``with open(...) as file:`` |
| 61 | +# snippet, which returns a ``file`` context manager. In this way, it can be used to |
| 62 | +# override a parameter for a single command, or a sequence of commands. An application |
| 63 | +# of :class:`pygmt.config` as a context manager is shown below: |
67 | 64 |
|
68 | 65 | fig = pygmt.Figure()
|
69 | 66 |
|
|
72 | 69 | fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)
|
73 | 70 | fig.coast(land="black", water="skyblue")
|
74 | 71 |
|
75 |
| -# Shift plot origin down by 10cm to plot another map |
76 |
| -fig.shift_origin(yshift="-10c") |
| 72 | +# Shift plot origin down by the height of the figure to plot another map |
| 73 | +fig.shift_origin(yshift="-h") |
77 | 74 |
|
78 | 75 | # This figure retains the default "fancy" frame
|
79 | 76 | fig.basemap(region=[115, 119.5, 4, 7.5], projection="M10c", frame=True)
|
|
0 commit comments