pygmt.params.Pattern

class pygmt.params.Pattern(pattern, 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:

The 90 predefined bit-patterns provided with GMT
Parameters:
  • pattern (int | str | PathLike) –

    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

    • Name of a 1-, 8-, or 24-bit image raster file, to create customized, repeating images using image raster files.

  • dpi (int | None, default: None) – Resolution of the pattern in dots per inch (DPI) [Default is 300].

  • bgcolor/fgcolor – The background/foreground color for predefined bit-patterns or 1-bit images. Setting either 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].

  • invert (bool, default: False) – If True, the pattern will be bit-inverted, i.e., white and black areas will be interchanged (only applies to predefined bit-patterns or 1-bit images).

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()

Attributes

Examples using pygmt.params.Pattern

Bit and hachure patterns

Bit and hachure patterns

Cartesian histograms

Cartesian histograms

Plotting focal mechanisms

Plotting focal mechanisms

Plotting polygons

Plotting polygons