-
Notifications
You must be signed in to change notification settings - Fork 254
Implement the Perspective class for specifying viewpoint #4201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seisman
wants to merge
19
commits into
main
Choose a base branch
from
AliasSystem/perspective
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
88bcf72
Implement the Perspective class for specifying viewpoint
seisman 02ae339
Improve docstrings
seisman 3be6a08
Add a doctest
seisman 648c823
Merge branch 'main' into AliasSystem/perspective
seisman 202cf22
Improve the class
seisman dd31cec
Merge branch 'main' into AliasSystem/perspective
seisman 9807b0b
Remove some parameters
seisman e9aa78f
Rename zlevel to level
seisman ad7e338
Skip doctest and use _validate
seisman af31b7a
Update type hints for the perspective parameter
seisman 637806e
Revert unrelated changes in text
seisman adf1cc1
Fix styling
seisman edfd30d
Improve the docstrings for the perspective parameter
seisman 9b01b2a
Merge branch 'main' into AliasSystem/perspective
seisman 53354d6
Merge branch 'main' into AliasSystem/perspective
seisman 28de054
Improve docstrings
seisman 8068b10
Update docstrings
seisman 4148a76
Merge branch 'main' into AliasSystem/perspective
seisman 4363537
Merge branch 'main' into AliasSystem/perspective
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,6 +217,7 @@ Class-style Parameters | |
| Box | ||
| Frame | ||
| Pattern | ||
| Perspective | ||
| Position | ||
|
|
||
| Enums | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| """ | ||
| The Perspective class for setting perspective view. | ||
| """ | ||
|
|
||
| import dataclasses | ||
| from typing import Literal | ||
|
|
||
| from pygmt.alias import Alias | ||
| from pygmt.exceptions import GMTValueError | ||
| from pygmt.params.base import BaseParam | ||
|
|
||
| __doctest_skip__ = ["Perspective"] | ||
|
|
||
|
|
||
| @dataclasses.dataclass(repr=False) | ||
| class Perspective(BaseParam): | ||
| """ | ||
| Class for setting perspective view. | ||
|
|
||
| Examples | ||
| -------- | ||
| >>> import pygmt | ||
| >>> from pygmt.params import Perspective | ||
| >>> fig = pygmt.Figure() | ||
| >>> fig.basemap( | ||
| ... region=[0, 10, 0, 10, 0, 20], | ||
| ... projection="X3c", | ||
| ... zsize="3c", | ||
| ... frame=["xafg", "yafg", "zafg", "wSEnZ"], | ||
| ... perspective=Perspective(azimuth=135, elevation=40, level=10), | ||
| ... ) | ||
| >>> fig.show() | ||
| """ | ||
|
|
||
| #: Azimuth of the viewpoint in degrees. Default is 180.0 (looking from south to | ||
| #: north). | ||
| azimuth: float | None = None | ||
|
|
||
| #: Elevation angle of the viewpoint in degrees. Default is 90.0 (looking straight | ||
| #: down at nadir). | ||
| elevation: float | None = None | ||
|
|
||
| #: The level at which all 2-D material, like the plot frame, is plotted. Only valid | ||
| #: when used together with parameters ``zsize``/``zscale``. Default is at the bottom | ||
| #: of the selected axis. | ||
| level: float | None = None | ||
|
|
||
| #: Set which constant-coordinate plane is used as the plotting plane. Use ``"x"``, | ||
| #: ``"y"``, or ``"z"`` for the x-plane, y-plane, or horizontal z-plane, | ||
| #: respectively [Default is ``"z"``]. | ||
| plane: Literal["x", "y", "z"] | None = None | ||
|
|
||
| def _validate(self): | ||
| """ | ||
| Post-initialization processing to validate parameters. | ||
| """ | ||
| # azimuth is required, so it must be set to the default if not specified. | ||
| if self.azimuth is None: | ||
| self.azimuth = 180.0 # Default azimuth is 180.0 | ||
|
|
||
| # Set default elevation if level is set but elevation is not. | ||
| if self.level is not None and self.elevation is None: | ||
| self.elevation = 90.0 # Default elevation is 90.0 | ||
|
|
||
| if self.plane is not None and self.plane not in {"x", "y", "z"}: | ||
| raise GMTValueError( | ||
| self.plane, description="plane", choices={"x", "y", "z"} | ||
| ) | ||
|
|
||
| @property | ||
| def _aliases(self): | ||
| """ | ||
| Aliases for the parameters. | ||
| """ | ||
| return [ | ||
| Alias(self.plane, name="plane"), | ||
| Alias(self.azimuth, name="azimuth"), | ||
| Alias(self.elevation, name="elevation", prefix="/"), | ||
| Alias(self.level, name="level", prefix="/"), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.