Skip to content
Merged
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
18 changes: 17 additions & 1 deletion pygmt/src/grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from typing import Literal

import xarray as xr
from packaging.version import Version
from pygmt._typing import PathLike
from pygmt.alias import Alias, AliasSystem
from pygmt.clib import Session
from pygmt.clib import Session, __gmt_version__
from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring, use_alias
from pygmt.src.grdinfo import grdinfo

__doctest_skip__ = ["grdview"]

Expand Down Expand Up @@ -116,6 +118,8 @@ def grdview( # noqa: PLR0913
value in the grid. However, if ``region`` was used to set *zmin/zmax* then
*zmin* is used if it is less than the grid minimum value. Use ``facade_pen`` and
``facade_fill`` to control the appearance of the plane.
**Note**: For GMT<=6.6.0, *zmin* set in ``region`` has no effect due to a GMT
bug.
facade_fill
Fill for the frontal facade between the plane specified by ``plane`` and the
data perimeter.
Expand Down Expand Up @@ -174,6 +178,18 @@ def grdview( # noqa: PLR0913
if plane is False and (facade_fill is not None or facade_pen is not None):
plane = True

# Workaround for GMT bug https://github.com/GenericMappingTools/gmt/pull/8838
# Fix the plane value to be the grid minimum if plane=True.
# Notes:
# 1. It's the minimum of the grid, not a subset of the grid defined by 'region'.
# 2. The GMT docs says "if -R was used to set zmin/zmax then we use that value if
# it is less than the grid minimum value.". We can't add a workaround for this
# case since we can't parse zmin/zmax from 'region' if 'region' was set in
# previous plotting commands.
# TODO(GMT>6.6.0): Remove this workaround.
if Version(__gmt_version__) <= Version("6.6.0") and plane is True:
plane = grdinfo(grid, per_column=True).split()[4]

aliasdict = AliasSystem(
Jz=Alias(zscale, name="zscale"),
JZ=Alias(zsize, name="zsize"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: cfff4879fbe7ab03d8a304b2622b9782
size: 26208
- md5: aa725f7d05462e7d272cf7045a7c9913
size: 32037
hash: md5
path: test_grdview_facadepen_default_plane.png
Loading