spharpy.plot#

Classes:

MidpointNormalize([vmin, vmax, midpoint, clip])

Colormap norm with a defined midpoint.

Functions:

balloon(coordinates, data[, cmap, phase, ...])

Plot data on a sphere defined by the coordinate angles theta and phi.

balloon_wireframe(coordinates, data[, cmap, ...])

Plot data on a sphere defined by the coordinate angles theta and phi.

contour(coordinates, data[, limits, cmap, ...])

Plot the map projection of data points sampled on a spherical surface.

contour_map(coordinates, data[, projection, ...])

Plot the map projection of data points sampled on a spherical surface.

pcolor_map(coordinates, data[, projection, ...])

Plot the map projection of data points sampled on a spherical surface.

pcolor_sphere(coordinates, data[, cmap, ...])

Plot data on the surface of a sphere defined by the coordinate angles theta and phi.

phase_twilight([lut])

Cyclic color map for displaying phase information.

scatter(coordinates[, ax])

Plot the x, y, and z coordinates of the sampling grid in the 3d space.

voronoi_cells_sphere(sampling[, ...])

Plot the Voronoi cells of a Voronoi tesselation on a sphere.

class spharpy.plot.MidpointNormalize(vmin=None, vmax=None, midpoint=0.0, clip=False)[source]#

Bases: Normalize

Colormap norm with a defined midpoint. Useful for normalization of colormaps representing deviations from a defined midpoint. Taken from the official matplotlib documentation at https://matplotlib.org/users/colormapnorms.html

Methods:

__init__([vmin, vmax, midpoint, clip])

param vmin:

If vmin and/or vmax is not given, they are initialized from the

__init__(vmin=None, vmax=None, midpoint=0.0, clip=False)[source]#
Parameters:
  • vmin (float or None) – If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).

  • vmax (float or None) – If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e., __call__(A) calls autoscale_None(A).

  • clip (bool, default: False) –

    If True values falling outside the range [vmin, vmax], are mapped to 0 or 1, whichever is closer, and masked values are set to 1. If False masked values remain masked.

    Clipping silently defeats the purpose of setting the over, under, and masked colors in a colormap, so it is likely to lead to surprises; therefore the default is clip=False.

Notes

Returns 0 if vmin == vmax.

spharpy.plot.balloon(coordinates, data, cmap=None, phase=False, show=True, colorbar=True, ax=None, *args, **kwargs)[source]#

Plot data on a sphere defined by the coordinate angles theta and phi. The magnitude information is mapped onto the radius of the sphere. The colormap represents either the phase or the magnitude of the data array.

Note

When plotting the phase encoded in the colormap, the function will switch to the HSV colormap and ignore the user input for the cmap input variable.

Parameters:
  • coordinates (spharpy.samplings.Coordinates, pf.Coordinates) – Coordinates defining a sphere

  • data (ndarray, double) – Data for each angle, must have size corresponding to the number of points given in coordinates.

  • cmap (matplotlib colomap, optional) – Colormap for the plot, see matplotlib.cm

  • phase (boolean, optional) – Encode the phase of the data in the colormap. This option will be activated by default of the data is complex valued.

  • show (boolean, optional) – Wheter to show the figure or not

spharpy.plot.balloon_wireframe(coordinates, data, cmap=None, phase=False, show=True, colorbar=True, ax=None)[source]#

Plot data on a sphere defined by the coordinate angles theta and phi. The magnitude information is mapped onto the radius of the sphere. The colormap represents either the phase or the magnitude of the data array.

Note

When plotting the phase encoded in the colormap, the function will switch to the HSV colormap and ignore the user input for the cmap input variable.

Parameters:
  • coordinates (spharpy.samplings.Coordinates, pf.Coordinates) – Coordinates defining a sphere

  • data (ndarray, double) – Data for each angle, must have size corresponding to the number of points given in coordinates.

  • cmap (matplotlib colomap, optional) – Colormap for the plot, see matplotlib.cm

  • phase (boolean, optional) – Encode the phase of the data in the colormap. This option will be activated by default of the data is complex valued.

  • show (boolean, optional) – Whether to show the figure or not

spharpy.plot.contour(coordinates, data, limits=None, cmap=<matplotlib.colors.ListedColormap object>, show=True, ax=None)[source]#

Plot the map projection of data points sampled on a spherical surface. The data has to be real-valued.

Notes

In case limits are given, all out of bounds data will be clipped to the respective limit.

Parameters:
  • coordinates (spharpy.samplings.Coordinates, pf.Coordinates) – Coordinates defining a sphere

  • data (ndarray, double) – Data for each angle, must have size corresponding to the number of points given in coordinates.

  • show (boolean, optional) – Wheter to show the figure or not

spharpy.plot.contour_map(coordinates, data, projection='mollweide', limits=None, cmap=<matplotlib.colors.ListedColormap object>, colorbar=True, show=True, levels=None, ax=None)[source]#

Plot the map projection of data points sampled on a spherical surface. The data has to be real.

Notes

In case limits are given, all out of bounds data will be clipped to the respective limit.

Parameters:
  • latitude (ndarray, double) – Geodetic latitude angle of the map, must be in [-pi/2, pi/2]

  • longitude (ndarray, double) – Geodetic longitude angle of the map, must be in [-pi, pi]

  • data (ndarray, double) – Data for each angle, must have size corresponding to the number of points given in coordinates.

  • show (boolean, optional) – Wheter to show the figure or not

spharpy.plot.pcolor_map(coordinates, data, projection='mollweide', limits=None, cmap=<matplotlib.colors.ListedColormap object>, show=True, refine=False, ax=None, **kwargs)[source]#

Plot the map projection of data points sampled on a spherical surface. The data has to be real.

Notes

In case limits are given, all out of bounds data will be clipped to the respective limit.

Parameters:
  • coordinates (spharpy.samplings.Coordinates, pf.Coordinates) – Coordinates defining a sphere

  • data (ndarray, double) – Data for each angle, must have size corresponding to the number of points given in coordinates.

  • show (boolean, optional) – Wheter to show the figure or not

spharpy.plot.pcolor_sphere(coordinates, data, cmap=None, colorbar=True, show=True, phase=False, ax=None, *args, **kwargs)[source]#

Plot data on the surface of a sphere defined by the coordinate angles theta and phi. The data array will be mapped onto the surface of a sphere.

Note

When plotting the phase encoded in the colormap, the function will switch to the HSV colormap and ignore the user input for the cmap input variable.

Parameters:
  • coordinates (spharpy.samplings.Coordinates, pf.Coordinates) – Coordinates defining a sphere

  • data (ndarray, double) – Data for each angle, must have size corresponding to the number of points given in coordinates.

  • cmap (matplotlib colomap, optional) – Colormap for the plot, see matplotlib.cm

  • phase (boolean, optional) – Encode the phase of the data in the colormap. This option will be activated by default of the data is complex valued.

  • ax (matplotlib.axis, None, optional) – The matplotlib axis object used for plotting. By default None, which will create a new axis object.

  • show (boolean, optional) – Whether to show the figure or not

spharpy.plot.phase_twilight(lut=512)[source]#

Cyclic color map for displaying phase information. This is a modified version of the twilight color map from matplotlib.

spharpy.plot.scatter(coordinates, ax=None)[source]#

Plot the x, y, and z coordinates of the sampling grid in the 3d space.

Parameters:

coordinates (spharpy.samplings.Coordinates, pf.Coordinates) – The coordinates to be plotted

spharpy.plot.voronoi_cells_sphere(sampling, round_decimals=13, ax=None)[source]#

Plot the Voronoi cells of a Voronoi tesselation on a sphere.

Parameters:
  • sampling (spharpy.samplings.SamplingSphere, pf.Coordinates) – Sampling as SamplingSphere object

  • round_decimals (int) – Decimals to be rounded to for eliminating duplicate points in the voronoi diagram

  • ax (AxesSubplot, None, optional) – The subplot axes to use for plotting. The used projection needs to be ‘3d’.