Decorated lines

To draw a so-called decorated line, i.e., symbols along a line or curve, use the style parameter of the pygmt.Figure.plot method with the argument "~" and the desired modifiers. A colon (":") is used to separate the algorithm settings from the symbol information. This example shows how to adjust the symbols. Beside the built-in symbols also custom symbols can be used. For modifying the main decorated line via the pen parameter, see the Line styles example. For details on the input data see the upstream GMT documentation at Furthermore, there are so-called line fronts, which are often used to plot fault lines, subduction zones, or weather fronts; for details see the Line fronts example.

decorated lines
import numpy as np
import pygmt

# Generate a two-point line for plotting
x = np.array([1, 4])
y = np.array([24, 24])

fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 24], projection="X15c", frame="+tDecorated Lines")

# Plot different decorated lines
for decoline in [
    # Line with circles ("c") of 0.5 centimeters radius in distance of 1 centimeter
    # Adjust thickness, color, and style of the outline via "+p"
    # Here, we plot a 1-point thick, blue, dashed outline
    # Add a fill color using "+g" with the desired color
    # To use a pattern as fill append "p" and give the pattern number
    # Line with triangles ("t")
    # Rotate counter-clockwise from line-parallel ("+ap") by 30 degrees
    # Line with inverse triangles with a size of 0.3 centimeters in a
    # distance of 0.4 centimeters
    # Line with squares ("s") with a size of 0.7 centimeters in a distance of
    # 1 centimeter
    # Shift symbols using "+n" in x and y directions relative to the main decorated line
    # Give the number of equally spaced symbols by using "n" instead of "d"
    # Use upper-case "N" to have symbols at the start and end of the line
    # Suppress the main decorated line by appending "+i"
    # To only plot a symbol at the start of the line use "N-1"
    # To only plot a symbol at the end of the line use "N+1"
    # Line with stars ("a")
    # Line with crosses ("x")
    # Line with (vertical) lines or bars ("y")
    # Use custom symbol ("k") "squaroid" with a size of 0.5 centimeters
    y = y - 1.2  # Move current line down
    fig.plot(x=x, y=y, style=decoline, pen="1.25p,black")

Total running time of the script: (0 minutes 0.348 seconds)

Gallery generated by Sphinx-Gallery