Skip to content

Commit e86bd00

Browse files
committed
Improve the gallery example for patterns
1 parent fb1dbd1 commit e86bd00

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

examples/gallery/symbols/patterns.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Bit and hachure patterns
33
========================
44
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.
77
88
Example method parameters that support bit and hachure patterns include:
99
@@ -20,33 +20,33 @@
2020
- :meth:`pygmt.Figure.wiggle`: Anomalies via ``fillpositive`` and ``fillnegative``
2121
2222
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
2624
: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.
2729
"""
2830

2931
# %%
3032
import pygmt
33+
from pygmt.params import Pattern
3134

3235
# 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.
3537
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),
5050
]
5151

5252
fig = pygmt.Figure()

0 commit comments

Comments
 (0)