|
| 1 | +""" |
| 2 | +Line styles |
| 3 | +----------- |
| 4 | +
|
| 5 | +The :meth:`pygmt.Figure.plot` method can plot lines in different styles. |
| 6 | +The default line style is a 0.25-point wide, black, solid line, and can be |
| 7 | +customized via the ``pen`` argument. |
| 8 | +
|
| 9 | +A *pen* in GMT has three attributes: *width*, *color*, and *style*. |
| 10 | +The *style* attribute controls the appearance of the line. |
| 11 | +Giving “dotted” or “.” yields a dotted line, whereas a dashed pen is requested |
| 12 | +with “dashed” or “-”. Also combinations of dots and dashes, like “.-” for a |
| 13 | +dot-dashed line, are allowed. |
| 14 | +
|
| 15 | +For more advanced *pen* attributes, see the GMT cookbook |
| 16 | +:gmt-docs:`cookbook/features.html#wpen-attrib`. |
| 17 | +
|
| 18 | +""" |
| 19 | + |
| 20 | +import numpy as np |
| 21 | +import pygmt |
| 22 | + |
| 23 | +# Generate a sample line for plotting |
| 24 | +x = np.linspace(0, 10, 500) |
| 25 | +y = np.sin(x) |
| 26 | + |
| 27 | +fig = pygmt.Figure() |
| 28 | +fig.basemap(region=[0, 10, -3, 3], projection="X15c/8c", frame=["xaf", "yaf", "WSrt"]) |
| 29 | + |
| 30 | +# Plot the line using the default line style |
| 31 | +fig.plot(x=x, y=y) |
| 32 | + |
| 33 | +# Plot the lines using different line styles |
| 34 | +fig.plot(x=x, y=y + 1.5, pen="1p,red,-") |
| 35 | +fig.plot(x=x, y=y + 1.0, pen="2p,blue,.") |
| 36 | +fig.plot(x=x, y=y + 0.5, pen="1p,red,-.") |
| 37 | + |
| 38 | +fig.plot(x=x, y=y - 0.5, pen="2p,blue,..-") |
| 39 | +fig.plot(x=x, y=y - 1.0, pen="3p,tomato,--.") |
| 40 | +fig.plot(x=x, y=y - 1.5, pen="3p,tomato,4_2:2p") |
| 41 | + |
| 42 | +fig.show() |
0 commit comments