Skip to content

Implement the Perspective class for specifying viewpoint - #4201

Open
seisman wants to merge 20 commits into
mainfrom
AliasSystem/perspective
Open

Implement the Perspective class for specifying viewpoint#4201
seisman wants to merge 20 commits into
mainfrom
AliasSystem/perspective

Conversation

@seisman

@seisman seisman commented Nov 11, 2025

Copy link
Copy Markdown
Member

Implement the Perspective class for the -p option. See #4176 for related discussions.

Notes:

  • level is used rather than zlevel, because strictly speaking it can set the level for x-, y-, or z-planes.
  • +w/+v are not implemented yet, but they're mainly for animations so not frequently used.

Preview:

@seisman seisman added the feature Brand new feature label Nov 15, 2025
@seisman
seisman marked this pull request as ready for review June 25, 2026 14:44
@seisman seisman added the needs review This PR has higher priority and needs review. label Jun 25, 2026
@seisman seisman added this to the 0.19.0 milestone Jun 25, 2026
@seisman seisman removed the needs review This PR has higher priority and needs review. label Jun 30, 2026
@seisman seisman modified the milestones: 0.19.0, 0.20.0 Jun 30, 2026
@seisman seisman added the needs review This PR has higher priority and needs review. label Aug 13, 2026
@seisman
seisman requested a lite review from Copilot August 13, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new class-style parameter, pygmt.params.Perspective, to represent GMT’s -p perspective option in a more structured way, and wires it into the public plotting API and documentation.

Changes:

  • Added Perspective (pygmt/params/perspective.py) plus unit tests to validate its string serialization and error handling.
  • Updated many plotting wrappers’ perspective type annotations/imports to accept a Perspective object.
  • Updated parameter documentation and the API docs index to include Perspective.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pygmt/tests/test_params_perspective.py Adds tests for Perspective string formatting and invalid plane handling.
pygmt/src/wiggle.py Updates perspective type annotation to accept Perspective.
pygmt/src/vlines.py Updates perspective type annotation to accept Perspective.
pygmt/src/velo.py Updates perspective type annotation to accept Perspective.
pygmt/src/tilemap.py Updates perspective type annotation to accept Perspective.
pygmt/src/text.py Updates perspective type annotation to accept Perspective.
pygmt/src/ternary.py Updates perspective type annotation to accept Perspective.
pygmt/src/solar.py Updates perspective type annotation to accept Perspective.
pygmt/src/scalebar.py Updates perspective type annotation to accept Perspective.
pygmt/src/rose.py Updates perspective type annotation to accept Perspective.
pygmt/src/plot3d.py Updates perspective type annotation to accept Perspective.
pygmt/src/plot.py Updates perspective type annotation to accept Perspective.
pygmt/src/meca.py Updates perspective type annotation to accept Perspective.
pygmt/src/magnetic_rose.py Updates perspective type annotation to accept Perspective.
pygmt/src/logo.py Updates perspective type annotation to accept Perspective.
pygmt/src/legend.py Updates perspective type annotation to accept Perspective.
pygmt/src/image.py Updates perspective type annotation to accept Perspective.
pygmt/src/hlines.py Updates perspective type annotation to accept Perspective.
pygmt/src/histogram.py Updates perspective type annotation to accept Perspective.
pygmt/src/grdview.py Updates perspective type annotation to accept Perspective.
pygmt/src/grdimage.py Updates perspective type annotation to accept Perspective.
pygmt/src/grdcontour.py Updates perspective type annotation to accept Perspective.
pygmt/src/fill_between.py Updates perspective type annotation to accept Perspective.
pygmt/src/directional_rose.py Updates perspective type annotation to accept Perspective.
pygmt/src/contour.py Updates perspective type annotation to accept Perspective.
pygmt/src/colorbar.py Updates perspective type annotation to accept Perspective.
pygmt/src/coast.py Updates perspective type annotation to accept Perspective.
pygmt/src/basemap.py Updates perspective type annotation to accept Perspective.
pygmt/params/perspective.py Implements the new Perspective parameter class.
pygmt/params/init.py Exposes Perspective from pygmt.params.
pygmt/helpers/decorators.py Updates the shared perspective parameter docstring text.
doc/api/index.rst Adds Perspective to the “Class-style Parameters” API docs list.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pygmt/src/plot.py
Comment thread pygmt/helpers/decorators.py
@seisman
seisman requested a lite review from Copilot August 22, 2026 06:51
@seisman
seisman requested a review from a team August 22, 2026 06:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated no new comments.

Suppressed comments (2)

pygmt/src/plot.py:63

  • The updated type annotation for perspective drops str, but perspective is still accepted as a raw GMT -p string by the alias system (AliasSystem.add_common uses Alias(value, sep="/", size={2, 3}), which treats strings as scalars). Dropping str makes the public typing inconsistent with runtime behavior and removes the only typed way to pass advanced -p modifiers not covered by Perspective yet (e.g., +w/+v).
    panel: int | Sequence[int] | bool = False,
    incols: int | str | Sequence[int | str] | None = None,
    perspective: Perspective | float | Sequence[float] | bool = False,
    transparency: float | Sequence[float] | bool | None = None,

pygmt/helpers/decorators.py:283

  • The perspective docstring no longer mentions that callers can still pass a raw string with the full GMT -p syntax (including +w/+v modifiers). Since the alias system still accepts strings for p (see pygmt/alias.py:374-375), this makes the documentation misleading and removes the only documented path for features not yet covered by Perspective.
            Accepts a :class:`pygmt.params.Perspective` object, a single value
            *azimuth*, a sequence of two values (*azimuth*, *elevation*), a sequence of
            three values (*azimuth*, *elevation*, *level*).

            - *azimuth*: Azimuth angle of the viewpoint in degrees [Default is 180,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Brand new feature needs review This PR has higher priority and needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants