|
2 | 2 | plot - Plot in two dimensions.
|
3 | 3 | """
|
4 | 4 |
|
| 5 | +from typing import Literal |
| 6 | + |
5 | 7 | from pygmt.clib import Session
|
6 | 8 | from pygmt.exceptions import GMTInvalidInput
|
7 | 9 | from pygmt.helpers import (
|
|
49 | 51 | )
|
50 | 52 | @kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
|
51 | 53 | def plot(
|
52 |
| - self, data=None, x=None, y=None, size=None, symbol=None, direction=None, **kwargs |
| 54 | + self, |
| 55 | + data=None, |
| 56 | + x=None, |
| 57 | + y=None, |
| 58 | + size=None, |
| 59 | + symbol=None, |
| 60 | + direction=None, |
| 61 | + straight_line: bool | Literal["x", "y"] = False, # noqa: ARG001 |
| 62 | + **kwargs, |
53 | 63 | ):
|
54 | 64 | r"""
|
55 | 65 | Plot lines, polygons, and symbols in 2-D.
|
@@ -98,18 +108,29 @@ def plot(
|
98 | 108 | depending on the style options chosen.
|
99 | 109 | {projection}
|
100 | 110 | {region}
|
101 |
| - straight_line : bool or str |
102 |
| - [**m**\|\ **p**\|\ **x**\|\ **y**]. |
103 |
| - By default, geographic line segments are drawn as great circle |
104 |
| - arcs. To draw them as straight lines, use |
105 |
| - ``straight_line=True``. |
106 |
| - Alternatively, add **m** to draw the line by first following a |
107 |
| - meridian, then a parallel. Or append **p** to start following a |
108 |
| - parallel, then a meridian. (This can be practical to draw a line |
109 |
| - along parallels, for example). For Cartesian data, points are |
110 |
| - simply connected, unless you append **x** or **y** to draw |
111 |
| - stair-case curves that whose first move is along *x* or *y*, |
112 |
| - respectively. |
| 111 | + straight_line |
| 112 | + By default, line segments are drawn as straight lines in the Cartesian and polar |
| 113 | + coordinate systems, and as great circle arcs (by resampling coarse input data |
| 114 | + along such arcs) in the geographic coordinate system. The ``straight_line`` |
| 115 | + parameter can control the drawing of line segments. Valid values are: |
| 116 | +
|
| 117 | + - ``True``: Draw line segments as straight lines in geographic coordinate |
| 118 | + systems. |
| 119 | + - ``"x"``: Draw line segments by first along *x*, then along *y*. |
| 120 | + - ``"y"``: Draw line segments by first along *y*, then along *x*. |
| 121 | +
|
| 122 | + Here, *x* and *y* have different meanings depending on the coordinate system: |
| 123 | +
|
| 124 | + - **Cartesian** coordinate system: *x* and *y* are the X- and Y-axes. |
| 125 | + - **Polar** coordinate system: *x* and *y* are theta and radius. |
| 126 | + - **Geographic** coordinate system: *x* and *y* are parallels and meridians. |
| 127 | +
|
| 128 | + .. attention:: |
| 129 | +
|
| 130 | + There exits a bug in GMT<=6.5.0 that, in geographic coordinate systems, the |
| 131 | + meaning of *x* and *y* is reversed, i.e., *x* means meridians and *y* means |
| 132 | + parallels. The bug is fixed by upstream |
| 133 | + `PR #8648 <https://github.com/GenericMappingTools/gmt/pull/8648>`__. |
113 | 134 | {frame}
|
114 | 135 | {cmap}
|
115 | 136 | offset : str
|
@@ -206,6 +227,8 @@ def plot(
|
206 | 227 | ``x``/``y``.
|
207 | 228 | {wrap}
|
208 | 229 | """
|
| 230 | + # TODO(GMT>6.5.0): Remove the note for the upstream bug of the "straight_line" |
| 231 | + # parameter. |
209 | 232 | kwargs = self._preprocess(**kwargs)
|
210 | 233 |
|
211 | 234 | kind = data_kind(data)
|
|
0 commit comments