Creating a map with contour lines
Plotting a contour map is handled by
Create contour plot
pygmt.Figure.grdcontour method takes the grid input.
It plots annotated contour lines, which are thicker and have the
elevation/depth written on them, and unannotated contour lines.
In the example below, the default contour line intervals are 500 meters,
with an annotated contour line every 1,000 meters.
By default, it plots the map with the
equidistant cylindrical projection and with no frame.
Contour line settings
interval parameters to adjust contour line
intervals. In the example below, there are contour intervals every 250 meters
and annotated contour lines every 1,000 meters.
limit parameter sets the minimum and maximum values for the contour
lines. The parameter takes the low and high values, and is either a list (as
below) or a string
pygmt.Figure.grdcontour method accepts additional parameters,
including setting the projection and frame.
Adding a colormap
pygmt.Figure.grdimage method can be used to add a
colormap to the contour map. It must be called prior to
pygmt.Figure.grdcontour to keep the contour lines visible on the
final map. If the
projection parameter is specified in the
pygmt.Figure.grdimage method, it does not need to be repeated in the
pygmt.Figure.grdcontour method. Finally, a colorbar is added using
Total running time of the script: ( 0 minutes 4.170 seconds)