-
Notifications
You must be signed in to change notification settings - Fork 234
Description
GMT’s -p option enables perspective view by setting the azimuth and elevation of the viewpoint. The full documentation is available at:
https://docs.generic-mapping-tools.org/6.6/gmt.html#perspective-full
The GMT command-line syntax is rather complex:
-p[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0]At present, we must pass the raw string directly to the perspective parameter in the first plotting command, and then specify perspective=True in subsequent commands. This approach feels un-Pythonic.
One possible improvement is to define an auxiliary class that can be passed to the perspective parameter, for example:
perspective = Perspective(azimuth, elevation, zlevel, ...)However, a more Pythonic design might be to provide a method—similar to Matplotlib’s [view_init](https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.view_init.html)—that allows setting the perspective once and reusing it, like so:
import pygmt
fig = pygmt.Figure()
fig.set_perspective(azimuth=xxx, elevation=xxx, zlevel=xxx)
fig.basemap(region=xxx, projection=xxx, perspective=True)
fig.coast(..., perspective=True)
fig.text(...) # No perspective parameter neededWith this approach, the perspective parameter can simply take a boolean value—True to apply the perspective settings defined by fig.set_perspective, and False to disable them. This would also simplify the docstring for the perspective parameter.
This is still an early idea, and I’d appreciate any feedback before proceeding with implementation.