Skip to content

Commit 66c435f

Browse files
authored
How use colors (#19)
* add first rst * Add color tutorial
1 parent 8e9dc47 commit 66c435f

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

docs/index.rst

+7
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,10 @@ Basics
113113
:align: center
114114

115115
:doc:`tutorials/basics/region`
116+
117+
- .. image:: _images/42eb572e679e97489f2a5029a5d74352.png
118+
:target: tutorials/basics/color.html
119+
:width: 80%
120+
:align: center
121+
122+
:doc:`tutorials/basics/color`

docs/tutorials/basics/color.rst

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
How to use colors
2+
-----------------
3+
4+
In GMT you will want to define the color of different features (line, symbols, polygones, text, etc.).
5+
There are six methods to define a color:
6+
7+
* `Color names`_
8+
* `R/G/B`_
9+
* `#RRGGBB`_
10+
* `Graylevel`_
11+
* `H-S-V`_
12+
* `C/M/Y/K`_
13+
14+
Color names
15+
~~~~~~~~~~~
16+
17+
This is more friendly way to define a color. There are 663 unique color names that can be selected.
18+
All names are case-insensitive. You can see the names (and their RGB values) in this
19+
`link <https://docs.generic-mapping-tools.org/latest/_images/GMT_RGBchart.png>`_
20+
or use this interactive :gmt-module:`color-picker`.
21+
22+
In the following example, we use ``lightgray`` for the dry areas and ``royalblue4`` for the wet areas.
23+
24+
.. gmtplot::
25+
26+
gmt begin color png
27+
gmt coast -Rd -JW12c -Glightgray -Sroyalblue4
28+
gmt end show
29+
30+
Color models
31+
~~~~~~~~~~~~
32+
Alternatively, you can also use color models to define a color.
33+
These are useful especially when you know the values that define the color you want to use.
34+
GMT identifies the color model according to the syntax used.
35+
36+
R/G/B
37+
=====
38+
39+
Provide 3 values each from 0 to 255 separated by a /.
40+
Specify **R**\ed, **G**\reen, and **B**\lue levels.
41+
Each value is separated by a slash and is in the range from 0 (dark) to 255 (light).
42+
This representation is used to color monitors.
43+
44+
45+
#RRGGBB
46+
=======
47+
48+
Specify Red, Green, and Blue levels in the way that it is done in HTML.
49+
Use two characters for each color channel, ranging from 00 (dark) to FF (light).
50+
Upper and lower case are allowed.
51+
52+
53+
Graylevel
54+
=========
55+
56+
Specify a single number from 0 (black) to 255 (white). It only uses shades of gray (R = G = B).
57+
This representation is popular with black and white printers.
58+
59+
60+
H-S-V
61+
=====
62+
63+
Specify **H**\ue in the range 0 to 360 (degrees), **S**\aturation between 0 (not saturated) and 1 (fully saturated), and **V**\alue between 0 (dark) and 1 (light). Number are separated by hyphens. This representation can be helpful when hue varies a lot.
64+
65+
66+
C/M/Y/K
67+
=======
68+
69+
Specify **C**\yan, **M**\agenta, **Y**\ellow, and blac**K**. Each number is in the range from 0 (no paint) to 100 (maximum paint). This representation is used by most color printers.
70+
71+
72+
Example with color model
73+
========================
74+
It is possible to make the previous map with color models.
75+
76+
Color models for ``royalblue4``:
77+
78+
* R/G/B: 39/64/139
79+
* #RRGGBB: #27408B
80+
* H-S-V: 225-0.719-0.545
81+
* C/M/Y/K: 72/54/0/45
82+
83+
Color models for ``lightgray``:
84+
85+
* R/G/B: 211/211/211
86+
* #RRGGBB: #D3D3D3
87+
* Graylevel: 211
88+
* H-S-V: 0-0-0.827
89+
* C/M/Y/K: 0/0/0/17
90+
91+
92+
.. gmtplot::
93+
94+
gmt begin color png
95+
gmt coast -Rd -JW12c -G211 -S39/64/139
96+
gmt end show

0 commit comments

Comments
 (0)