Skip to content

Conversation

@seisman
Copy link
Member

@seisman seisman commented Dec 2, 2025

This PR improves grdview's -Q option in a more Pythonic way by splitting it into multiple parameters:

  • surftype
  • dpi
  • nan_transparent
  • monochrome
  • mesh_fill

Address #4208 (comment).

Example

import pygmt

grd_relief = pygmt.datasets.load_earth_relief(resolution="15m", region=[-25, -13, 63.2, 66.7])

args = dict(
    region=[-25, -13, 63.2, 66.7], 
    projection="M?", 
    perspective=(-150, 25),
    cmap="SCM/oleron",
    zsize="1.5c",
    plane="+ggray",
    panel=True,
)

fig = pygmt.Figure()
with fig.subplot(nrows=5, ncols=3, subsize=(5, 5), margins=(1, 0.2)):
    for surftype in ("surface", "mesh", "surface+mesh", "image", "waterfallx", "waterfally"):
        fig.grdview(
            grid=grd_relief,
            frame=["xaf", "yaf", f"WSenZ+t{surftype}"],
            surftype=surftype,
            **args,
        )
    for surftype in ("surface", "mesh", "surface+mesh", "image", "waterfallx", "waterfally"):
        fig.grdview(
            grid=grd_relief,
            frame=["xaf", "yaf", f"WSenZ+t{surftype}"],
            surftype=surftype,
            monochrome=True,
            **args,
        )
    for surtype in ("mesh", "waterfallx", "waterfally"):
        fig.grdview(
            grid=grd_relief,
            frame=["xaf", "yaf", f"WSenZ+t{surftype}"],
            surftype=surftype,
            meshfill="red@50",
            **args,
        )
fig.show()
map

Comment on lines 194 to 200
"image": "c" if nan_transparent is True else "i",
"waterfallx": "mx",
"waterfally": "my",
}

# surftype was aliased to Q previously.
_old_surftype_syntax = surftype not in _surtype_mapping and surftype is not None
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a unit test to ensure that backwards compatibility is preserved when a user passes surftype="c", but did not set nan_transparent=True (which is added in this PR). The output grdview plot should still have NaN transparency.

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

Labels

enhancement Improving an existing feature

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants