Skip to content

Figure.grdview: Create 3-D perspective image or surface mesh from a grid #4208

Closed

Description

@seisman

This issue serves as the central place for discussing and tracking the implementation of the grdview method in PyGMT. The issue will be closed when the initial implementation is complete. Progress is tracked at PyGMT: Wrapping GMT modules.

Documentation

GMT Option Flags and Modifieres

☑️: Implemented; ⬜: To be implemented/discussed; Strikethrough: Won't implement.

Linked Pull Requests

Related Issues and Discussions

Add links to related wrapper discussions, API design threads, or upstream GMT changes here.

Activity

  1. added this to the 0.1.x milestone on Nov 13, 2025
  2. added
    feature request
    on Nov 13, 2025
  3. seisman commented on Nov 13, 2025

    @seisman
    MemberAuthor

    -Q option is one of the commonly used options in grdview. Its full syntax is -Qc|i|m[x|y]|s[m][color][+m], with full documentation at https://docs.generic-mapping-tools.org/6.6/grdview.html#q.

    It will be used in the Figure 3 of the PyGMT paper, so we need to make it Pythonic. Below is an example showing the possible use cases of this option:

    import pygmt
    
    grd_relief = pygmt.datasets.load_earth_relief(resolution="15m", region=[-25, -13, 63.2, 66.7])
    
    fig = pygmt.Figure()
    with fig.subplot(nrows=4, ncols=3, subsize=(5, 5), margins=(1, 0.2)):
        for surftype in ("c", "i", "i50", "m", "mx", "my", "mlightblue", "mxgreen", "mylightred", "s", "sm", "s+m"):
            fig.grdview(
                region=[-25, -13, 63.2, 66.7], 
                projection="M?", 
                frame=["xaf", "yaf", f"WSenZ+t{surftype}"],
                perspective=(-150, 25),
                grid=grd_relief,
                cmap="SCM/oleron",
                surftype=surftype,
                zsize="1.5c",
                plane="+ggray",
                panel=True,
            )
    fig.show()

    The output image is:

    Image

    So, what is the Pythonic way to specify this option?

    1. The parameter surftype can be used to control the plot type. Its possible values are:
      • "surface": mapped to "s", i.e., surface plot
      • "mesh": mapped to "m", i.e., mesh plot
      • "surface_mesh"/"surface+mesh": mapped to "sm", surface plot with mesh lines on top
      • "waterfallx"/waterfall_x: mapped to "mx", waterfall plot in x direction
      • "waterfally"/waterfall_y: mapped to "my", waterfall plot in y direction
      • "image": mapped to "i", i.e., image plot
    2. More parameters are needed to cover more complicated cases:
      • Parameter nan_transparent: surftype="c" is similar to "i" for an image plot, with transparent NaN nodes. So, surftype="image", nan_transparent=True is mapped to "c". The parameter name nan_transparent is the same as grdimage's -Q option.
      • Parameter dpi: Set the dpi for image plot "i" or "c". The parameter name is the same as grdimage's -E option
      • meshfill/meshcolor: Set the color (patterns are allowed, so fill makes more sense) for mesh and waterfall plots.
      • Parameter monochrome: For the modifier +m. The name is the same as grdimage's -M option

    Also see the GMT.jl documentation for reference.

    Any comments?

  4. moved this from 0) Wishlist to 3) Complete aliases in PyGMT: Wrapping GMT moduleson Dec 2, 2025
  5. moved this from 3) Complete aliases to 4) Gallery|tutorial example in PyGMT: Wrapping GMT moduleson Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions