Creating a 3D perspective image¶
Create 3-D perspective image or surface mesh from a grid
pygmt.Figure.grdview method takes the
perspective parameter changes the azimuth and elevation of the viewpoint; the
default is [180, 90], which is looking directly down on the figure and north is “up”.
zsize parameter sets how tall the three-dimensional portion appears.
The default grid surface type is mesh plot.
fig = pygmt.Figure() fig.grdview( grid=grid, # Sets the view azimuth as 130 degrees, and the view elevation as 30 degrees perspective=[130, 30], # Sets the x- and y-axis labels, and annotates the west, south, and east axes frame=["xa", "ya", "WSnE"], # Sets a Mercator projection on a 15-centimeter figure projection="M15c", # Sets the height of the three-dimensional relief at 1.5 centimeters zsize="1.5c", ) fig.show()
The grid surface type can be set with the
The default CPT is turbo and can be customized with the
plane parameter sets the elevation and color of a plane that provides a fill
below the surface relief.
perspective azimuth can be changed to set the direction that is “up”
in the figure. The
contourpen parameter sets the pen used to draw contour lines
on the surface.
pygmt.Figure.colorbar can be used to add a color bar to the
cmap parameter does not need to be passed again. To keep the color
bar’s alignment similar to the figure, use
True as the
fig = pygmt.Figure() fig.grdview( grid=grid, # Set the azimuth to -130 (230) degrees and the elevation to 30 degrees perspective=[-130, 30], frame=["xaf", "yaf", "WSnE"], projection="M15c", zsize="1.5c", surftype="s", cmap="geo", plane="1000+ggrey", # Set the contour pen thickness to "0.1p" contourpen="0.1p", ) fig.colorbar(perspective=True, frame=["a500", "x+lElevation", "y+lm"]) fig.show()
Total running time of the script: ( 0 minutes 6.074 seconds)