utils.plotUtils

Module: utils.plotUtils

Basic plotting tools

Functions:
utils.plotUtils.addColorbar(mappable, ax)[source]

Append colorbar to axes

Args:
  • mappable: a mappable object
  • ax: an axes object
Returns:
  • cbax: colorbar axes object

Note

This is mostly useful for axes created with curvedEarthAxes().

written by Sebastien, 2013-04

utils.plotUtils.curvedEarthAxes(rect=111, fig=None, minground=0.0, maxground=2000, minalt=0, maxalt=500, Re=6371.0, nyticks=5, nxticks=4)[source]

Create curved axes in ground-range and altitude

Args:
  • [rect]: subplot spcification
  • [fig]: A pylab.figure object (default to gcf)
  • [maxground]: maximum ground range [km]
  • [minalt]: lowest altitude limit [km]
  • [maxalt]: highest altitude limit [km]
  • [Re]: Earth radius
Returns:
  • ax: matplotlib.axes object containing formatting
  • aax: matplotlib.axes object containing data
Example:
import numpy as np
from utils import plotUtils
ax, aax = plotUtils.curvedEarthAxes()
th = np.linspace(0, ax.maxground/ax.Re, 50)
r = np.linspace(ax.Re+ax.minalt, ax.Re+ax.maxalt, 20)
Z = exp( -(r - 300 - ax.Re)**2 / 100**2 ) * np.cos(th[:, np.newaxis]/th.max()*4*np.pi)
x, y = np.meshgrid(th, r)
im = aax.pcolormesh(x, y, Z.T)
ax.grid()

written by Sebastien, 2013-04

utils.plotUtils.drawCB(fig, coll, cmap, norm, map=False, pos=[0, 0, 1, 1])[source]

manually draws a colorbar on a figure. This can be used in lieu of the standard mpl colorbar function if you need the colorbar in a specific location. See pydarn.plotting.rti.plotRti() for an example of its use.

Args:

Returns:

Example:
cmap,norm,bounds = genCmap('velocity', [-200,200], colors='aj', lowGray=True)

Written by AJ 20120820

utils.plotUtils.genCmap(param, scale, colors='lasse', lowGray=False)[source]

Generates a colormap and returns the necessary components to use it

Args:
  • param (str): the parameter being plotted (‘velocity’ and ‘phi0’ are special cases, anything else gets the same color scale)
  • scale (list): a list with the [min,max] values of the color scale
  • [colors] (str): a string indicating which colorbar to use, valid inputs are ‘lasse’, ‘aj’. default = ‘lasse’
  • [lowGray] (boolean): a flag indicating whether to plot low velocities (|v| < 15 m/s) in gray. default = False
Returns:
  • cmap (matplotlib.colors.ListedColormap): the colormap generated. This then gets passed to the mpl plotting function (e.g. scatter, plot, LineCollection, etc.)
  • norm (matplotlib.colors.BoundaryNorm): the colormap index. This then gets passed to the mpl plotting function (e.g. scatter, plot, LineCollection, etc.)
  • bounds (list): the boundaries of each of the colormap segments. This can be used to manually label the colorbar, for example.
Example:
cmap,norm,bounds = genCmap('velocity', [-200,200], colors='aj', lowGray=True)

Written by AJ 20120820

class utils.plotUtils.mapObj(datetime=None, coords='geo', projection='stere', resolution='c', dateTime=None, lat_0=None, lon_0=None, boundinglat=None, width=None, height=None, fillContinents='.8', fillOceans='None', fillLakes=None, coastLineWidth=0.0, grid=True, gridLabels=True, showCoords=True, **kwargs)[source]

This class wraps arround mpl_toolkits.basemap.Basemap (<http://tinyurl.com/d4rzmfo>)

Members:
  • coords (str): map coordinate system (‘geo’, ‘mag’, ‘mlt’).
  • all members of mpl_toolkits.basemap.Basemap (<http://tinyurl.com/d4rzmfo>)
Methods:
Example:
# Create the map
myMap = utils.mapObj(boundinglat=30, coords='mag')
# Plot the geographic and geomagnetic North Poles
# First convert from lat/lon to map projection coordinates...
x, y = myMap(0., 90., coords='geo')
# ...then plot
myMap.scatter(x, y, zorder=2, color='r')
# Convert to map projection...
x, y = myMap(0., 90., coords='mag')
# ...and plot
myMap.scatter(x, y, zorder=2, color='g')

Note

Once the map is created, all plotting calls will be assumed to already be in the map’s declared coordinate system given by coords.

utils.plotUtils.textHighlighted(xy, text, color='k', fontsize=None, xytext=(0, 0), zorder=None, text_alignment=(0, 0), xycoords='data', textcoords='offset points', **kwargs)[source]

Plot highlighted annotation (with a white lining)

Belongs to: rbspFp

Args:
  • xy: position of point to annotate
  • text: text to show
  • [xytext]: text position
  • [zorder]: text zorder
  • [color]: text color
  • [fontsize]: text font size
  • [xycoords]: xy coordinate (see matplotlib.pyplot.annotate<http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.annotate>)
  • [textcoords]: text coordinate (see matplotlib.pyplot.annotate<http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.annotate>)
utils.plotUtils

alias of utils.plotUtils

Previous topic

utils.timeUtils

Next topic

utils.geoPack

This Page