Add the Perspective class for setting perspective view
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- python
- Domain
- data-visualization
Research direction
The issue names no files or tests; start by reviewing Figure plotting commands and the existing perspective parameter. Compare the proposed Perspective class and set_perspective approach with GMT’s -p syntax. Done requires an agreed API and implementation scope for setting, reusing, and disabling perspective settings.
Written by the indexing model from the issue text.
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 needed
With 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.
- Dominant language
- Python
- Stars
- 882
- Forks
- 261
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 29
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GenericMappingTools/pygmt
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GenericMappingTools/pygmt#5014 · 1 comment ·
Maintainers usually reply within 1 day
-
discussions documentation
Difficulty 1/5 Under an hour Newbie friendliness 78/100
GenericMappingTools/pygmt#4992 ·
Maintainers usually reply within 1 day
-
Improve reporting the GMT version via "pygmt.show_versions()"Possibly taken @yvonnefroehlich claimed this 114 days ago. Openmaintenance
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
GenericMappingTools/pygmt#4812 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
GenericMappingTools/pygmt#4765 ·
Maintainers usually reply within 1 day
-
Add an AGENTS.md filePossibly taken A pull request linked to this issue is open or already merged. Opendiscussions
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
GenericMappingTools/pygmt#4677 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
All issues in GenericMappingTools/pygmt
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TigreGotico/orthography2ipa#2950 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Unstructured-IO/unstructured#4876 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openfoodfacts/openfoodfacts-python#579 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
fairagro/m4.2_sql_to_arc#388 ·
Maintainers usually reply within 1 day