Skip to content

Pygmt#203

Closed
MarkWieczorek wants to merge 15 commits intoSHTOOLS:developfrom
MarkWieczorek:pygmt
Closed

Pygmt#203
MarkWieczorek wants to merge 15 commits intoSHTOOLS:developfrom
MarkWieczorek:pygmt

Conversation

@MarkWieczorek
Copy link
Member

@MarkWieczorek MarkWieczorek commented Nov 8, 2019

Plotting of global geographically projected data is now supported by the SHGrid method plot_gmt(). This routine makes use of pygmt which is based on the generic-mapping-tools. At present, only the plotting of global or hemispherical maps are supported. Non-global projections will be added later, which will require additional parameters.

Plotting can be as simple as

fig = grid.plot_gmt()
fig.show()  # for a jupyter notebook, or fig.show(method='external') for the terminal
fig.savefig('fig.pdf')

Numerous human-readable options are provided for setting projections, colorbars, adjusting ticks, annotations, and data limits.

Examples

fig = grid.plot_gmt(projection='mollweide', colorbar='horizontal', cb_label='Elevation (km)', cmap='Roma', cmap_reverse=True, cmap_limits=[-6, 14], cb_annotate_interval=5, cb_tick_interval=1)

mars-mollweide

fig = grid.plot_gmt(projection='orthographic', latitude=-10, longitude=-90, colorbar='vertical', cb_label='Elevation (km)', cmap='vik', cmap_limits=[-11, 15], cb_annotate_interval=5, cb_tick_interval=1)

mars-ortho

fig = grid.plot_gmt(projection='winkel-tripel', longitude=-90, colorbar='vertical', cb_label='Elevation (km)', cmap='vik', cmap_limits=[-11, 15], cb_annotate_interval=5, cb_tick_interval=1)

mars-winkel-tripel

fig = grid.plot_gmt(projection='cylindrical', longitude=-90, colorbar='horizontal', cb_label='Elevation (km)', annotate=True, ticks=True, cmap='vik', cmap_limits=[-11, 15], cb_annotate_interval=5, cb_tick_interval=1)

mars-cylindrical

Docstring

        Plot projected data using the Generic Mapping Tools (pygmt).

        To display the figure in a jupyter notebook, use
            fig.show()
        To display the figure in the terminal environment, use
            fig.show(method='external')

        Usage
        -----
        fig = x.plotgmt([fig, projection, region, width, unit,
                         central_latitude, central_longitude, center, grid,
                         annotate, ticks, axes, title, cmap, cmap_limits, cmap_reverse,
                         cmap_continuous, colorbar, cb_triangles,
                         cb_label, cb_ylabel, cb_annotate,
                         cb_annotate_interval, cb_ticks, cb_tick_interval,
                         horizon, offset, fname])

        Returns
        -------
        fig : pygmt.figure.Figure class instance

        Parameters
        ----------
        fig : pygmt.Figure() class instance, optional, default = None
            If provided, the plot will be placed in a pre-existing figure.
        projection : str, optional, default = 'mollweide'
            The name of a global or hemispherical projection (see Notes). Only
            the first three characters are necessary to identify the
            projection.
        region : str or list, optional, default = 'g'
            The map region, consisting of a list [West, East, South, North] in
            degrees. The default 'g' specifies the entire sphere.
        width : float, optional, default = mpl.rcParams['figure.figsize'][0]
            The width of the projected image.
        unit : str, optional, default = 'i'
            The measurement unit of the figure width and offset: 'i' for
            inches or 'c' for cm.
        central_longitude : float, optional, default = 0
            The central meridian or center of the projection.
        central_latitude : float, optional, default = 0
            The center of the projection used with hemispheric projections, or
            the standard parallel used with cylindrical projections.
        center : list, optional, default = None
            The center of the projection, which is by default given by
            [central_longitude, central_latitude].
        grid : list, optional, default = [30, 30]
            Grid line interval [longitude, latitude] in degrees. If None, grid
            lines will not be plotted for that axis.
        annotate : list, optional, default = [None, None]
            Annotation label interval [longitude, latitude] in degrees. If
            None, annotations will not be plotted for that axis.
        ticks : list, optional, default = [None, None]
            Tick interval [longitude, latitude] in degrees. If None, ticks will
            not be plotted for that axis.
        axes : str, optional, default = 'WSen'
            Specify which plot axes should be drawn and annotated. Capital
            letters draw the axes, ticks, and annotations, whereas small
            letters draw only the axes and ticks.
        title : str, optional, default = None
            The title to be displayed above the plot.
        cmap : str, optional, default = 'viridis'
            The color map to use when plotting the data and colorbar.
        cmap_limits : list, optional, default = [self.min(), self.max()]
            Set the lower and upper limits of the colormap used to plot the
            data, and optionally an interval.
        cmap_reverse : bool, optional, default = False
            Set to True to reverse the sense of the color progression in the
            color table.
        cmap_continuous : bool, optional, default = False
            If True, create a continuous colormap. Default behavior is to
            use contant colors for each interval.
        colorbar : str, optional, default = None
            Plot a colorbar that is either 'horizontal' or 'vertical'.
        cb_triangles : str, optional, default = 'both'
            Add triangles to the edges of the colorbar for minimum and maximum
            values. Can be 'neither', 'both', 'min', or 'max'.
        cb_label : str, optional, default = None
            Text label for the colorbar.
        cb_ylabel : str, optional, default = None
            Text label for the y axis of the colorbar
        cb_annotate : bool, optional, default = True
            If True, plot annotation labels on the colorbar.
        cb_annotate_interval : float, optional, default = None
            Annotation interval on the colorbar.
        cb_ticks : bool, optional, default = True
            If True, plot ticks on the colorbar.
        cb_tick_interval : float, optional, default = None
            Colorbar tick interval.
        horizon : float, optional, default = 60
            The horizon (number of degrees from the center to the edge) used
            with the Gnomonic projection.
        offset : list, optional, default = [None, None]
            Offset of the plot in the x and y directions from the current
            origin.
        fname : str, optional, default = None
            If present, save the image to the specified file.

        Notes
        -----
        Global and hemispherical projections (region='g') with corresponding
        abbreviation used by `projection`:

        Azimuthal projections
            Lambert-azimuthal-equal-area (lam)
            Stereographic-equal-angle (ste)
            Orthographic (ort)
            Azimuthal-equidistant (azi)
            Gnomonic (gno)

        Cylindrical projections (case sensitive)
            cylindrical-equidistant (cyl)
            Cylindrical-equal-area (Cyl)
            CYLindrical-stereographic (CYL)
            Miller-cylindrical (mil)

        Miscellaneous projections
            Mollweide (mol)
            Hammer (ham)
            Winkel-Tripel (win)
            Robinson (rob)
            Eckert (eck)
            Sinusoidal (sin)

@MarkWieczorek MarkWieczorek added this to the GMT milestone Nov 8, 2019
@MarkWieczorek
Copy link
Member Author

This old PR is incorporated into

#209

@MarkWieczorek MarkWieczorek deleted the pygmt branch July 23, 2020 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant