|
| 1 | +""" |
| 2 | +Basic geometric symbols |
| 3 | +----------------------- |
| 4 | +
|
| 5 | +The :meth:`pygmt.Figure.plot` method can plot individual geometric symbols |
| 6 | +by passing the corresponding shortcuts to the ``style`` parameter. The 14 basic |
| 7 | +geometric symbols are shown underneath their corresponding shortcut codes. |
| 8 | +Four symbols (**-**, **+**, **x** and **y**) are line-symbols only for which we |
| 9 | +can adjust the linewidth via the ``pen`` parameter. The point symbol (**p**) |
| 10 | +only takes a color fill which we can define via the ``color`` parameter. For the |
| 11 | +remaining symbols we may define a linewidth as well as a color fill. |
| 12 | +
|
| 13 | +""" |
| 14 | + |
| 15 | +import pygmt |
| 16 | + |
| 17 | +fig = pygmt.Figure() |
| 18 | +fig.basemap(region=[0, 8, 0, 3], projection="X12c/4c", frame=True) |
| 19 | + |
| 20 | +# define fontstlye for annotations |
| 21 | +font = "15p,Helvetica-Bold" |
| 22 | + |
| 23 | +# upper row |
| 24 | +y = 2 |
| 25 | + |
| 26 | +# use a dash in x direction (-) with a size of 0.9 cm, |
| 27 | +# linewidth is set to 2p and the linecolor to "gray40" |
| 28 | +fig.plot(x=1, y=y, style="-0.9c", pen="2p,gray40") |
| 29 | +fig.text(x=1, y=y + 0.6, text="-", font=font) |
| 30 | + |
| 31 | +# use a plus (+) with a size of 0.9 cm, |
| 32 | +# linewidth is set to 2p and the linecolor to "gray40" |
| 33 | +fig.plot(x=2, y=y, style="+0.9c", pen="2p,gray40") |
| 34 | +fig.text(x=2, y=y + 0.6, text="+", font=font) |
| 35 | + |
| 36 | +# use a star (a) with a size of 0.9 cm, |
| 37 | +# linewidth is set to 1p, the linecolor to "black" (default) and the |
| 38 | +# color fill to "darkorange" |
| 39 | +fig.plot(x=3, y=y, style="a0.9c", pen="1p,black", color="darkorange") |
| 40 | +fig.text(x=3, y=y + 0.6, text="a", font=font) |
| 41 | + |
| 42 | +# use a circle (c) with a size of 0.9 cm, |
| 43 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 44 | +# color fill to "darkred" |
| 45 | +fig.plot(x=4, y=y, style="c0.9c", pen="1p,black", color="darkred") |
| 46 | +fig.text(x=4, y=y + 0.6, text="c", font=font) |
| 47 | + |
| 48 | +# use a diamond (d) with a size of 0.9 cm, |
| 49 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 50 | +# color fill to "seagreen" |
| 51 | +fig.plot(x=5, y=y, style="d0.9c", pen="1p,black", color="seagreen") |
| 52 | +fig.text(x=5, y=y + 0.6, text="d", font=font) |
| 53 | + |
| 54 | +# use a octagon (g) with a size of 0.9 cm, |
| 55 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 56 | +# color fill to "dodgerblue4" |
| 57 | +fig.plot(x=6, y=y, style="g0.9c", pen="1p,black", color="dodgerblue4") |
| 58 | +fig.text(x=6, y=y + 0.6, text="g", font=font) |
| 59 | + |
| 60 | +# use a hexagon (h) with a size of 0.9 cm, |
| 61 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 62 | +# color fill to "lightgray" |
| 63 | +fig.plot(x=7, y=y, style="h0.9c", pen="1p,black", color="lightgray") |
| 64 | +fig.text(x=7, y=y + 0.6, text="h", font=font) |
| 65 | + |
| 66 | +# lower row |
| 67 | +y = 0.5 |
| 68 | + |
| 69 | +# use an inverted triangle (i) with a size of 0.9 cm, |
| 70 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 71 | +# color fill to "tomato" |
| 72 | +fig.plot(x=1, y=y, style="i0.9c", pen="1p,black", color="tomato") |
| 73 | +fig.text(x=1, y=y + 0.6, text="i", font=font) |
| 74 | + |
| 75 | +# use pentagon (n) with a size of 0.9 cm, |
| 76 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 77 | +# color fill to "lightseagreen" |
| 78 | +fig.plot(x=2, y=y, style="n0.9c", pen="1p,black", color="lightseagreen") |
| 79 | +fig.text(x=2, y=y + 0.6, text="n", font=font) |
| 80 | + |
| 81 | +# use a point (p) with a size of 0.9 cm, |
| 82 | +# color fill is set to "lightseagreen" |
| 83 | +fig.plot(x=3, y=y, style="p0.9c", color="slateblue") |
| 84 | +fig.text(x=3, y=y + 0.6, text="p", font=font) |
| 85 | + |
| 86 | +# use square (s) with a size of 0.9 cm, |
| 87 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 88 | +# color fill to "gold2" |
| 89 | +fig.plot(x=4, y=y, style="s0.9c", pen="1p,black", color="gold2") |
| 90 | +fig.text(x=4, y=y + 0.6, text="s", font=font) |
| 91 | + |
| 92 | +# use triangle (t) with a size of 0.9 cm, |
| 93 | +# linewidth is set to 1p, the linecolor to "black" and the |
| 94 | +# color fill to "magenta4" |
| 95 | +fig.plot(x=5, y=y, style="t0.9c", pen="1p,black", color="magenta4") |
| 96 | +fig.text(x=5, y=y + 0.6, text="t", font=font) |
| 97 | + |
| 98 | +# use cross (x) with a size of 0.9 cm, |
| 99 | +# linewidth is set to 2p and the linecolor to "gray40" |
| 100 | +fig.plot(x=6, y=y, style="x0.9c", pen="2p,gray40") |
| 101 | +fig.text(x=6, y=y + 0.6, text="x", font=font) |
| 102 | + |
| 103 | +# use a dash in y direction (y) with a size of 0.9 cm, |
| 104 | +# linewidth is set to 2p and the linecolor to "gray40" |
| 105 | +fig.plot(x=7, y=y, style="y0.9c", pen="2p,gray40") |
| 106 | +fig.text(x=7, y=y + 0.6, text="y", font=font) |
| 107 | + |
| 108 | +fig.show() |
0 commit comments