Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

ex20.rst 4.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  1. .. _example_20:
  2. (20) Custom plot symbols
  3. ------------------------
  4. One is often required to make special maps that shows the distribution
  5. of certain features but one would prefer to use a custom symbol instead
  6. of the built-in circles, squares, triangles, etc. in the GMT plotting
  7. programs :doc:`plot </plot>` and
  8. :doc:`plot3d </plot3d>`. Here we demonstrate one approach
  9. that allows for a fair bit of flexibility in designing ones own symbols.
  10. The following recipe is used when designing a new symbol.
  11. #. Use :doc:`basemap </basemap>` (or engineering
  12. paper!) to set up an empty grid that goes from -0.5 to +0.5 in both
  13. *x* and *y*. Use ruler and compass to draw your new symbol using
  14. straight lines, arcs of circles, and stand-alone geometrical objects
  15. (see :doc:`plot </plot>` man page for a full
  16. description of symbol design). Here we will create two new
  17. symbols: a volcano and a bulls eye.
  18. .. figure:: /_images/GMT_volcano.*
  19. :width: 500 px
  20. :align: center
  21. #. After designing the symbol we will encode it using a simple set of
  22. rules. In our case we describe our volcano and bulls eye using these
  23. three freeform polygon generators:
  24. :math:`x_0` :math:`y_0` *r* **C** [ **-G**\ *fill* ] [
  25. **-W**\ *pen* ] Draw :math:`x_0` :math:`y_0` **M** [ **-G**\ *fill* ]
  26. [ **-W**\ *pen* ] Start new element at :math:`x_0`, :math:`y_0`
  27. :math:`x_1` :math:`y_1` **D** Draw straight line from current point
  28. to :math:`x_1`, :math:`y_1` around (:math:`x_0`, :math:`y_0`)
  29. :math:`x_0` :math:`y_0` *r* :math:`\alpha_1` :math:`\alpha_2`
  30. **A** Draw arc segment of radius *r* from angle
  31. :math:`\alpha_1` to :math:`\alpha_2`
  32. We also add a few stand-alone circles (for other symbols, see
  33. :doc:`plot </plot>` man page):
  34. :math:`x_0` :math:`y_0` *r* **C** [ **-G**\ *fill* ] [
  35. **-W**\ *pen* ] Draw :math:`x_0` :math:`y_0` *r* **c** [
  36. **-G**\ *fill* ] [ **-W**\ *pen* ] Draw single circle of radius
  37. *r* around :math:`x_0`, :math:`y_0`
  38. The optional **-G** and **-W** can be used to hardwire the color fill
  39. and pen for segments (use **-** to disallow fill or line for any
  40. specific feature). By default the segments are painted based on the
  41. values of the command line settings.
  42. Manually applying these rules to our volcano symbol results in a
  43. definition file ``volcano.def``:
  44. Without much further discussion we also make a definition file ``bullseye.def`` for a
  45. multi-colored bulls eye symbol. Note that the symbol can be created
  46. beyond the -0.5 to +0.5 range, as shown by the red lines. There is no
  47. limit in GMT to the size of the symbols. The center, however, will
  48. always be at (0,0). This is the point to which the coordinates in
  49. :doc:`plot </plot>` refers.
  50. The values refer to positions and dimensions illustrated in the
  51. Figure above.
  52. #. Given proper definition files we may now use them with
  53. :doc:`plot </plot>` or :doc:`plot3d </plot3d>`.
  54. We are now ready to give it a try. Based on the hotspot locations in the remote
  55. file ``hotspots.txt`` (with a 3rd column giving the desired symbol sizes in inches) we
  56. lay down a world map and overlay red volcano symbols using our
  57. custom-built volcano symbol and :doc:`plot </plot>`. We
  58. do something similar with the bulls eye symbols. Without the **-G**
  59. option, however, they get the colors defined in ``bullseye.def``.
  60. Here is our final map script that produces the Figure:
  61. .. literalinclude:: /_verbatim/ex20.txt
  62. :language: bash
  63. .. figure:: /_images/ex20.*
  64. :width: 500 px
  65. :align: center
  66. Using custom symbols in GMT.
  67. Given these guidelines you can easily make your own symbols. Symbols
  68. with more than one color can be obtained by making several symbol
  69. components. E.g., to have yellow smoke coming out of red volcanoes we
  70. would make two symbols: one with just the cone and caldera and the other
  71. with the bubbles. These would be plotted consecutively using the desired
  72. colors. Alternatively, like in ``bullseye.def``, we may specify colors directly for the
  73. various segments. Note that the custom symbols (:doc:`/cookbook/custom-symbols`),
  74. unlike the built-in symbols in GMT, can be used with the built-in
  75. patterns (:doc:`/cookbook/predefined-patterns`). Other approaches are also possible, of course.
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...