pygmt.params.Pattern
- class pygmt.params.Pattern(pattern=1, dpi=None, bgcolor=None, fgcolor=None, invert=False)[source]
Class for specifying bit and hachure patterns.
This class allows users to specify predefined bit-patterns or custom 1-, 8-, or 24-bit image raster files to fill symbols and polygons in various PyGMT plotting methods. The patterns can be customized with different resolution and different foreground and background colors. The foreground and background colors can also be inverted.
GMT provides 90 predefined patterns that can be used in PyGMT. The patterns are numbered from 1 to 90, and shown below:
Examples
Draw a global map with land areas filled with pattern 15 in a light red background and 200 dpi resolution:
>>> import pygmt >>> from pygmt.params import Pattern >>> fig = pygmt.Figure() >>> fig.coast( ... region="g", ... projection="H10c", ... frame=True, ... land=Pattern(15, bgcolor="lightred", dpi=200), ... shorelines=True, ... ) >>> fig.show()
-
pattern:
int
|str
|PathLike
= 1 The pattern to use. It can be specified in two forms:
An integer in the range of 1-90, corresponding to one of 90 predefined 64x64 bit-patterns. [Default is 1].
Name of a 1-, 8-, or 24-bit image raster file, to create customized, repeating images using image raster files.
-
bgcolor:
str
|None
= None The background color for predefined bit-patterns or 1-bit images. Setting either
bgcolor
orfgcolor
to an empty string will yield a transparent background/foreground where only the foreground/background pixels will be painted. [Default is white for background and black for foreground].
-
pattern: