|
2 | 2 | Bit and hachure patterns
|
3 | 3 | ========================
|
4 | 4 |
|
5 |
| -In addition to colors, PyGMT also allows using bit and hachure patterns to fill |
6 |
| -symbols, polygons, and other areas, via the ``fill`` parameter or similar parameters. |
| 5 | +In addition to colors, PyGMT also allows using bit and hachure patterns to fill symbols, |
| 6 | +polygons, and other areas, via the ``fill`` parameter or similar parameters. |
7 | 7 |
|
8 | 8 | Example method parameters that support bit and hachure patterns include:
|
9 | 9 |
|
|
20 | 20 | - :meth:`pygmt.Figure.wiggle`: Anomalies via ``fillpositive`` and ``fillnegative``
|
21 | 21 |
|
22 | 22 | GMT provides 90 predefined patterns that can be used in PyGMT. The patterns are numbered
|
23 |
| -from 1 to 90, and can be colored and inverted. The resolution of the pattern |
24 |
| -can be changed, and the background and foreground colors can be set. For a complete list |
25 |
| -of available patterns and the full syntax to specify a pattern, refer to the |
| 23 | +from 1 to 90. For a complete list of available patterns refer to the |
26 | 24 | :doc:`/techref/patterns`.
|
| 25 | +
|
| 26 | +In PyGMT, patterns can be specified via the {class}`pygmt.params.Pattern` class. The |
| 27 | +patterns can be customized with different resolution and different foreground and |
| 28 | +background colors. The foreground and background colors can also be reversed. |
27 | 29 | """
|
28 | 30 |
|
29 | 31 | # %%
|
30 | 32 | import pygmt
|
| 33 | +from pygmt.params import Pattern |
31 | 34 |
|
32 | 35 | # A list of patterns that will be demonstrated.
|
33 |
| -# To use a pattern as fill append "p" and the number of the desired pattern. |
34 |
| -# By default, the pattern is plotted in black and white with a resolution of 300 dpi. |
| 36 | +# By default, a pattern is plotted in black and white with a resolution of 1200 dpi. |
35 | 37 | patterns = [
|
36 |
| - # Plot a hachted pattern via pattern number 8 |
37 |
| - "p8", |
38 |
| - # Plot a dotted pattern via pattern number 19 |
39 |
| - "p19", |
40 |
| - # Set the background color ("+b") to "red3" and the foreground color ("+f") to |
41 |
| - # "lightgray" |
42 |
| - "p19+bred3+flightbrown", |
43 |
| - # Invert the pattern by using a capitalized "P" |
44 |
| - "P19+bred3+flightbrown", |
45 |
| - # Change the resolution ("+r") to 100 dpi |
46 |
| - "p19+bred3+flightbrown+r100", |
47 |
| - # Make the background transparent by not giving a color after "+b"; |
48 |
| - # works analogous for the foreground |
49 |
| - "p19+b+flightbrown+r100", |
| 38 | + # Predefined 1-bit pattern 8. |
| 39 | + Pattern(8), |
| 40 | + # Predefined 1-bit pattern 19. |
| 41 | + Pattern(19), |
| 42 | + # Pattern 19 with custom backgroud ("red3") and foreground ("lightbrown"). |
| 43 | + Pattern(19, bgcolor="red3", fgcolor="lightbrown"), |
| 44 | + # Reverse the background and foreground. |
| 45 | + Pattern(19, reversed=True, bgcolor="red3", fgcolor="lightbrown"), |
| 46 | + # Same as above, but with a 100 dpi resolution. |
| 47 | + Pattern(19, bgcolor="red3", fgcolor="lightbrown", dpi=100), |
| 48 | + # Same as above, but with a transparent background by setting bgcolor to "". |
| 49 | + Pattern(19, bgcolor="", fgcolor="lightbrown", dpi=100), |
50 | 50 | ]
|
51 | 51 |
|
52 | 52 | fig = pygmt.Figure()
|
|
0 commit comments