Skip to content

POC: Figure.clip: Clip paths by polygons, land or water #3878

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

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
.. rubric:: Attributes

{% for item in attributes %}
.. autoproperty::
{{ objname }}.{{ item }}
.. autoproperty:: {{ objname }}.{{ item }}
:no-index:
{% endfor %}
{% endif %}

Expand Down
2 changes: 2 additions & 0 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Plotting map elements
:toctree: generated

Figure.basemap
Figure.clip
Figure.coast
Figure.colorbar
Figure.hlines
Expand Down Expand Up @@ -226,6 +227,7 @@ Miscellaneous

which
show_versions
src.ClipAccessor

Datasets
--------
Expand Down
10 changes: 10 additions & 0 deletions pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Literal, overload

from pygmt._typing import PathLike
from pygmt.src import ClipAccessor

try:
import IPython
Expand Down Expand Up @@ -145,6 +146,15 @@ def region(self) -> np.ndarray:
wesn = lib.extract_region()
return wesn

@property
def clip(self) -> ClipAccessor:
"""
Set up a clipping path and only plot data inside/outside it.

See :class:`pygmt.src.clip.ClipAccessor <ClipAccessor>` for the usage.
"""
return ClipAccessor(self)

def savefig(
self,
fname: PathLike,
Expand Down
1 change: 1 addition & 0 deletions pygmt/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pygmt.src.basemap import basemap
from pygmt.src.binstats import binstats
from pygmt.src.blockm import blockmean, blockmedian, blockmode
from pygmt.src.clip import ClipAccessor
from pygmt.src.coast import coast
from pygmt.src.colorbar import colorbar
from pygmt.src.config import config
Expand Down
Loading
Loading