2.3.2. vacumm.misc.plot – Plots

Essential functions:
 
curve2 Plot 1D data as a curve and return a Curve object with properties also from Plot and Plot1D.
bar2 Plot data as a bar plot and return a Bar object with properties also from Plot and Plot1D.
hov2 Plot data as a Hovmoller diagram (2D with one axis as time) and get a Nov object.
map2 Plot an empty map or data on a map and return a Map object with properties also from Plot, Plot2D, ScalarMappable and QuiverKey.
section2 Plot geographical data as a vertical-horizontal section and return a Section object with properties also from Plot, Plot2D, ScalarMappable and QuiverKey.
stick2 Plot data as a stick plot and return a Stick object with properties also from Plot, Plot1D, Curve, ScalarMappable and QuiverKey.
rankhist Plot rank histogram
target Plot a (direct) target diagram from already computed statistics
taylor Plot a Taylor diagram after computing statistics
minimap Create a minimap with map2()
add_map_point Add a small map with a point at specified longitude and latitude
add_map_line Add a small map with a line at specified longitudes and latitudes
add_map_box Add a small map with a box at specified longitudes and latitudes
make_movie Make a movie from a series of figures
Attributes:
Functions:

Generic plots using Matplotlib and taking advantage of CDAT

Tutorial: “Graphics”.

add_agg_filter(objs, filter, zorder=None, ax=None, add=True)[source]

Add a filtered version of objects to plot

Params:
  • objs: matplotlib.artist.Artist instances.
  • filter: vacumm.misc._ext_plot.BaseFilter instance.
  • zorder, optional: zorder (else guess from objs).
  • ax, optional: class:matplotlib.axes.Axes instance.

Inspired from http://matplotlib.sourceforge.net/examples/pylab_examples/demo_agg_filter.html .

add_bottom_label(text, pos=0.1, ax=None, va='top', ha='center', rotation=0.0, shadow=False, glow=False, **kwargs)[source]

Add a text label to the left of a plot

add_colorbar(var=None, sm=None, horizontal=False, position=None, cmap=None, drawedges=False, axes=None, fig=None, figsize=None, frameon=None, levels=None, barwidth=None, barmargin=0.1, norm=None, **kwargs)[source]

Standalone colorbar

add_compass(x, y, size=40, facecolor1='k', facecolor2='w', edgecolor='k', text_color='k', text_size='medium', linewidth=0.5, alpha=1, text_pad=5, style='simple', angle=0, ax=None, m=None, anglemode='pixels', **kwpatch)[source]

Add a compass to the current plot

Params:
  • x/y: Position in data coordinates.
  • size, optional: size in opixels.
  • style, optional: “simple”, “fancy”.
  • angle, optional: Angle of the north (trigo).
  • anglemode, optional: “pixels” or “data”.
  • facecolor1, optional: Dark face color.
  • facecolor2, optional: Light face color.
  • edgecolor, optional: Edges color.
  • text_color, optional: Text labels color.
  • text_size, optional: Text labels size.
  • text_<param>, optional: <param> is passed to Text when adding labels.
  • fontsize/color, optional: Same as text_size/color.
add_glow(objs, width=3, zorder=None, color='w', ax=None, alpha=1.0, add=True)[source]

Add a glow effect to text

Params:
  • objs: Plotted objects.
  • width, optional: Width of the gaussian filter in points.
  • color, optional: Color of the shadow.
  • zorder, optional: zorder (else guess from objs).
  • ax, optional: class:matplotlib.axes.Axes instance.

Inspired from http://matplotlib.sourceforge.net/examples/pylab_examples/demo_agg_filter.html .

add_grid(gg, color='k', edges=True, centers=False, m=None, linecolor=None, xcorners=None, ycorners=None, linewidth=1, alpha=0.5, linestyle='solid', zorder=100, marker=', ', markersize=4, facecolor=None, edgecolor=None, markerlinewidth=0, label_edges='Cell edges', label_centers='Cell centers', samp=1, ax=None, **kwargs)[source]

Add a a 1D or 2D grid to a plot

Params:
  • gg: A cdms grid OR a (lon,lat) tuple of axes OR a cdms variable with a grid
  • x/ycorners: Corners coordinates (ny+1,nx+1)
  • borders: Display cell borders
  • centers: Display cell centers. If == 2, connect centers.
  • samp: Undersampling rate
  • m: A basemap instance to plot on
  • color: Default color (or c)
  • linecolor: Color of the lines (or lc) [defaults to color]
  • linestyle: Line style (or ls)
  • edgecolor: Edge color of marker (or ec) [defaults to color]
  • facecolor: Face color of marker (or fc) [defaults to color]
  • marker: Type of marker
  • markersize: Size of markers (or s)
  • alpha: Alpha transparency (or a)
  • zorder: Order of the grid in the stack (100 should be above all objects)
add_key(key=None, pos=1, fmt='%s)', xmargin=10, ymargin=10, fig=None, axes=None, **kwargs)[source]

Add a key to specify the plot number in a figure

Params:
  • key, optional: A string or a integer. If an integer is given, it converted to letter (1->’a’).

  • pos, optional: Position of the key. It can be an integer or string:

    • 1 = top left
    • 2 = top right
    • 3 = bottom right
    • 4 = bottom left

    If negative, push it outside axis box. It can also be an explicit position

  • fmt, optional: Format of the string.

  • {x|y}margin, optional: Margin from axes in points.

  • Other keywords are passed to text().

add_left_label(text, pos=0.1, ax=None, va='center', ha='left', rotation=90.0, shadow=False, glow=False, **kwargs)[source]

Add a text label to the left of a plot

add_lightshading(objs, width=7, fraction=0.5, zorder=None, ax=None, add=True, **kwargs)[source]

Add a light shading effect to objects

Params:
  • objs: Plotted objects.
  • width, optional: Width of the gaussian filter in points.
  • fraction, optional: Unknown.
  • zorder, optional: zorder (else guess from objs).
  • ax, optional: class:matplotlib.axes.Axes instance.
  • Extra keywords are passed to matplotlib.colors.LightSource

Inspired from http://matplotlib.sourceforge.net/examples/pylab_examples/demo_agg_filter.html .

Add a logo to the background of the figure

Warning

Except when loc='lower left', scale=1 is passed as arguments, the logo is rescaled each time the figure is resized.

Note

It is highly suggested to prefer png to other formats for your logo.

Params:
  • file: File of the image.
  • axes: Axes specs of the image (overwrites loc and scale keywords), passed to meth:~matplotlib.figure.Figure.add_axes.
  • loc: Position of the image (use words in ‘lower’, ‘upper’, ‘left’, ‘right’, ‘center’) .
  • scale: Scale the image. By default, it is auto scale so that the logo is never greater than 1/4 of the figure width or height.
  • alpha: Alpha transparency.
  • tool: None, ‘mpl’ (png only) or ‘pil’.
add_map_box(gg, box, color='r', linewidth=1.5, m=None, **kwargs)[source]

Add a small map with a box at specified longitudes and latitudes

Params:
  • gg: Map limits passed to minimap() or Map() instance.
  • box: Box limits in the forms [xmin,ymin,xmax,ymax] dict(x=(xmin,xmax),y=xmin,xmax) or dict(lon=(xmin,xmax),lat=xmin,xmax).
See also:

minimap() add_box()

add_map_line(gg, extents, color='r', linewidth=1.5, m=None, **kwargs)[source]

Add a small map with a line at specified longitudes and latitudes

Params:
  • gg: Map limits passed to minimap() or Map() instance.

  • extents: Extents in the forms [xmin,ymin,xmax,ymax] dict(x=(xmin,xmax),y=xmin,xmax) or

    dict(lon=(xmin,xmax),lat=xmin,xmax).

See also:

minimap() add_line()

add_map_lines(gg, xx, yy, color='r', linewidth=1.5, m=None, closed=False, **kwargs)[source]

Add a small map with a broken line specified longitudes and latitudes

Params:
  • gg: Map limits passed to minimap() or Map() instance.
  • xx/yy: 1D arrays of coordinates.
See also:

minimap() add_lines()

add_map_places(gg, lon, lat, txt, marker='o', color='r', size=40, m=None, alpha=1, **kwargs)[source]

Add a small map with one or several places at specified longitude and latitude

Params:
  • gg: Map limits passed to minimap() or Map() instance.
  • lon/lat: Coordinates arrays of the points.
  • txt: Text array associated to the points
See also:

minimap() add_place()

add_map_point(gg, lon, lat, marker='o', color='r', size=40, m=None, alpha=1, **kwargs)[source]

Add a small map with a point at specified longitude and latitude

Params:
  • gg: Map limits passed to minimap() or Map() instance.
  • lon/lat: Coordinates of the point.
See also:

minimap() add_point()

add_param_label(text, loc=(0.01, 0.01), color='0.4', size=8, family='monospace', fig=None, **kwargs)[source]

Add parameters description to the bottom/left of the figure

Example:
>>> c = curve2(sst, show=False)
>>> c.add_param_label(dict(max=.23, kz=0.25))
Params:
  • text: Either a string or a dictionary.
add_right_label(text, pos=0.1, ax=None, va='center', ha='right', rotation=-90.0, shadow=False, glow=False, **kwargs)[source]

Add a text label to the left of a plot

add_shadow(objs, width=3, xoffset=2, yoffset=-2, alpha=0.5, color='k', zorder=None, ax=None, add=True)[source]

Add a drop-shadow to objects

Params:
  • objs: matplotlib.artist.Artist instances.
  • width, optional: Width of the gaussian filter in points.
  • xoffset, optional: Shadow offset along X in points.
  • yoffset, optional: Shadow offset along Y in points.
  • color, optional: Color of the shadow.
  • zorder, optional: zorder (else guess from objs).
  • ax, optional: class:matplotlib.axes.Axes instance.

Inspired from http://matplotlib.sourceforge.net/examples/pylab_examples/demo_agg_filter.html .

add_time_mark(date, ymin=0, ymax=1, color='r', line=True, marker=True, shadow=False, label=None, zorder=200, ax=None, fig=None, **kwargs)[source]

Plot a time mark along a time axis using a line and a marker

Params:
  • date: Date (converted using mpl()).
  • color, optional: Color of the line and marker.
  • line, optional: Plot the line?
  • line_<kw>, optional: Keyword kw is passed to axvline().
  • marker, optional: Plot the marker? Or symbol.
  • line_<kw>, optional: Keyword kw is passed to axvline().
add_top_label(text, pos=0.1, ax=None, va='top', ha='center', rotation=0.0, shadow=False, glow=False, **kwargs)[source]

Add a text label to the left of a plot

bar2(data, width=1., lag=0, align='center', offset=None, title=None, savefig=None, show=True, **kwargs)[source]

Plot data as a bar plot and return a Bar object with properties also from Plot and Plot1D.

Examples:
>>> bar2(rain, color='c', align='left', width=0.95, savefig='rain.png')
>>> bar2(rain, vminmax=5.,show=False)
>>> bar2(snow, offset=rain, title='Precipitations')
Data params:
  • data: A MV2 1D array.
  • vertical, optional: Plot vertically.
  • axis, optional: Change plot axis.
  • long_name, optional: Force the long_name attribute used in title. See also param x/ylong_name.
  • units, optional: Force the units attribute used in labels (label, xlabel or ylabel).
Bar params:
  • width, optional: Relative width of the bars(0<width<1). a width of 1 means that successive are bars are joined.
  • lag, optional: Relative lag to apply to the position
  • align, optional: Alignment relative to coordinates.
  • offset, optional: Bars start at offset.
  • label, optional: Alternative label for the plot (see also label).
  • shadow, optional: Add a shadow to the bars.
  • shadow_<param>, optional: <param> is passed to add_shadow().
Plot initialization:
 
  • fig, optional: Figure number.
  • figsize, optional: Initialize the figure with this size.
  • subplot, optional: Call to subplot() to create axes.
  • subplots_adjust, optional: Dictionary sent to subplots_adjust(). You can also use keyparams ‘left’, ‘right’, ‘top’, ‘bottom’, ‘wspace’, ‘hspace’!
  • top/bottom/left/right/wspace/hspace, optional: Override subplots_adjust.
  • axes, optional: Use this axes object.
  • axes_<param>, optional: <param> is passed to axes().
  • axes_rect, optional: [left, bottom, width, height] in normalized (0,1) units to create axes using axes().
  • bgcolor, optional: Background axis color.
  • twin, optional: Use "x" or "y" or "xy" to make a copy of current X or Y axes (see matplotlib.pyplot.twinx()). You can also provide a dictionary : twin=dict(x=axes1, y=axes2).
  • noframe, optional: Suppress plot frames.
  • fullscreen, optional: Plot in full screen mode (thus, noframe==True).
Plot finalization:
 
  • title, optional: Force the title of the plot by setting title
  • title_<param>: <param> is passed to title()
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/y/vlim, optional: Force min/max of X or Y axis with (min,max)` like argument.
  • x/y/vminmax, optional: Minimal max value -> use this value if max is too low.
  • x/y/vmaxmin, optional: Maximal min value.
  • x/ymasked, optional: Force the plot to fit all data positions along X and/or Y, even if data is missing, by setting attributes xmasked, ymasked or xymasked.
  • x/ylong_name, optional: Same as long_name but for X and Y axes (xlong_name or ylong_name). It refers only to axes for 2D plots, and potentially to data for 1D plots.
  • x/yunits, optional: Same as units but for X and Y axes (xunits or yunits). It refers only to axes for 2D plots, and potentially to data for 1D plots. See also param x/yunits.
  • x/ylabel, optional: Force label used for X and Y axes by setting attributes xlabel or ylabel.
  • x/yticks, optional: Position of ticks.
  • x/yticklabels, optional: Label of ticks.
  • x/y/vskip, optional: Skip axis formating.
  • x/yhide, optional: Hide labels.
  • grid: Plot the grid [default: True]
  • grid_<param>: <param> is passed to grid()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • figtext: figtext Add text at a specified position on the figure. Example: figtext=[0,0,’text’] add a ‘text’ at the lower left corner, or simply figtext=’text’.
  • figtext_<param>: <param> is passed to figtext()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • key: Add a key (like ‘a)’) to the axes using add_key if different from None [default: None]
  • key_<param>: <param> is passed to add_key()
  • anchor: Anchor of the axes (useful when resizing) in [‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, ‘N’, ‘NW’, ‘W’].
  • autoresize: Auto resize the figure according axes (1 or True), axes+margins (2). If 0 or False, not resized [default: False=2].
  • savefig: Save the figure to this file.
  • savefig_verbose, optional: Informs about file name when written.
  • savefig_<param>: <param> is passed to method savefig() and finally to the matplotlib function savefig().
  • savefigs: Save the figure into multiple formats using savefigs() and ‘savefigs’ as the prefix to the files.
  • savefigs_<param>: <param> is passed to savefigs()
  • show: Display the figure [default: True]
  • close: Close the figure at the end [default: False]
colorbar(pp=None, vars=None, drawedges=False, levels=None, colorbar_horizontal=False, colorbar=True, colorbar_visible=True, colorbar_position=None, units=None, standalone=False, cax=None, extend='neither', **kwargs)[source]

Colorbar:

  • colorbar: Plot the colorbar [default: True]
  • colorbar_horizontal: Colorbar is horizontal [defaults: False]
  • colorbar_position: To change the default position. Position is relative to the SPACE LEFT in the form (center,width) with values in [0,1] [defaults: False]
  • colorbar_visible: Colorbar is visible [defaults: True]
  • colorbar_<keyword>: <keyword> is passed to colorbar()
  • units: Indicate these units on along the colorbar, else it guessed from the variable or suppressed if value is False [default: None]
curve2(data, parg=None, axis=None, title=None, savefig=None, show=True, **kwargs)[source]

Plot 1D data as a curve and return a Curve object with properties also from Plot and Plot1D.

Examples:
>>> curve2(sst, 'r-', shadow=True, ymax=25., long_name='SST', subplot=212)
>>> curve2(xe, label='Full signal', show=False)
>>> c = curve2(xef, label='Filtered signal', show=False)
>>> c.legend()
>>> c.savefig('xe.png')
Data params:
  • data: A MV2 1D array.
  • vertical, optional: Plot vertically.
  • axis, optional: Change plot axis.
  • long_name, optional: Force the long_name attribute used in title. See also param x/ylong_name.
  • units, optional: Force the units attribute used in labels (label, xlabel or ylabel).
Curve params:
  • parg, optional: Argument passed to plot() after the data.
  • nosingle, optional: Single point with missing data around are not plotted.
  • err, optional: Errors as (2,nx) array to add to the plot using errorbar().
  • err_<param>, optional: <param> is passed to errorbar().
  • fill_between, optional: Plot curve using fill_between(). Reference value defaults to 0. and may be given provided by the parameter.
  • fill_between_<param>, optional: <param> is passed to fill_between().
  • label, optional: Alternative label for the plot (see also label).
  • shadow, optional: A shadow is plotted below the line and points.
  • shadow_<param>, optional: <param> is passed to add_shadow().
Plot initialization:
 
  • fig, optional: Figure number.
  • figsize, optional: Initialize the figure with this size.
  • subplot, optional: Call to subplot() to create axes.
  • subplots_adjust, optional: Dictionary sent to subplots_adjust(). You can also use keyparams ‘left’, ‘right’, ‘top’, ‘bottom’, ‘wspace’, ‘hspace’!
  • top/bottom/left/right/wspace/hspace, optional: Override subplots_adjust.
  • axes, optional: Use this axes object.
  • axes_<param>, optional: <param> is passed to axes().
  • axes_rect, optional: [left, bottom, width, height] in normalized (0,1) units to create axes using axes().
  • bgcolor, optional: Background axis color.
  • twin, optional: Use "x" or "y" or "xy" to make a copy of current X or Y axes (see matplotlib.pyplot.twinx()). You can also provide a dictionary : twin=dict(x=axes1, y=axes2).
  • noframe, optional: Suppress plot frames.
  • fullscreen, optional: Plot in full screen mode (thus, noframe==True).
Plot finalization:
 
  • title, optional: Force the title of the plot by setting title
  • title_<param>: <param> is passed to title()
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/y/vlim, optional: Force min/max of X or Y axis with (min,max)` like argument.
  • x/y/vminmax, optional: Minimal max value -> use this value if max is too low.
  • x/y/vmaxmin, optional: Maximal min value.
  • x/ymasked, optional: Force the plot to fit all data positions along X and/or Y, even if data is missing, by setting attributes xmasked, ymasked or xymasked.
  • x/ylong_name, optional: Same as long_name but for X and Y axes (xlong_name or ylong_name). It refers only to axes for 2D plots, and potentially to data for 1D plots.
  • x/yunits, optional: Same as units but for X and Y axes (xunits or yunits). It refers only to axes for 2D plots, and potentially to data for 1D plots. See also param x/yunits.
  • x/ylabel, optional: Force label used for X and Y axes by setting attributes xlabel or ylabel.
  • x/yticks, optional: Position of ticks.
  • x/yticklabels, optional: Label of ticks.
  • x/y/vskip, optional: Skip axis formating.
  • x/yhide, optional: Hide labels.
  • grid: Plot the grid [default: True]
  • grid_<param>: <param> is passed to grid()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • figtext: figtext Add text at a specified position on the figure. Example: figtext=[0,0,’text’] add a ‘text’ at the lower left corner, or simply figtext=’text’.
  • figtext_<param>: <param> is passed to figtext()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • key: Add a key (like ‘a)’) to the axes using add_key if different from None [default: None]
  • key_<param>: <param> is passed to add_key()
  • anchor: Anchor of the axes (useful when resizing) in [‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, ‘N’, ‘NW’, ‘W’].
  • autoresize: Auto resize the figure according axes (1 or True), axes+margins (2). If 0 or False, not resized [default: False=2].
  • savefig: Save the figure to this file.
  • savefig_verbose, optional: Informs about file name when written.
  • savefig_<param>: <param> is passed to method savefig() and finally to the matplotlib function savefig().
  • savefigs: Save the figure into multiple formats using savefigs() and ‘savefigs’ as the prefix to the files.
  • savefigs_<param>: <param> is passed to savefigs()
  • show: Display the figure [default: True]
  • close: Close the figure at the end [default: False]
Extra:

A few matplotlib plot arguments can be passed (for exemple: linewidths).

decorate_axis(axis=None, vertical=0, date_rotation=None, date_fmt=None, date_locator=None, date_minor_locator=None, date_nominor=False, nodate=False, values=None, ax=None, **kwargs)[source]

Axis decoration:

  • [x/y]title: Main label of the axis.
  • [x/y]label: Same as x/ytitle.
  • [x/y]hide]: Hide x/ytick labels.
  • [x/y]rotation: Rotation of x/ytick labels (except for time).
  • [x/y]strict: Strict axis limit.
  • [x/y]lim: Override axis limit.
  • [x/y]min/max: Override axis limit by x/ylim.
  • [x/y]minmax/maxmin: Set maximal value of x/ymin and minimal value or x/ymax.
  • [x/y]nmax: Max number of ticks.
  • x/yfmt: Numeric format for x/y axis if not of time type.
  • date_rotation: Rotation of time ticklabels.
  • date_locator: Major locator for dates.
  • date_minor_locator: Minor locator for dates.
  • date_nominor: Suppress minor ticks for dates.
  • date_nmax_ticks: Max number of ticks for dates
  • nodate: Time axis must not be formatted as a time axis [default: False]
dtarget(bias, rmsc, stdmod, stdref=None, colors='cyan', sizes=20, title='Target diagram', cmap=None, units=None, colorbar=True, **kwargs)[source]

Plot a (direct) target diagram from already computed statistics

Params:
  • bias : Bias.
  • rmsc: Centered RMS error.
  • stdmod: Standard deviation of the model.
  • stdref, optional: Standard deviation of the observations.
  • colors, optional: Single or list of colors, or array of values, used to color markers.
  • sizes, optional: Single or list of sizes of markers.
  • title, optional: Title of the plot.
  • scatter_<keyword>, optional: <keyword> is passed to matplotlib.pyplot.scatter().
  • circle_<keyword>, optional: <keyword> is passed change the properties of circles.

Todo

Make two versions of target(), as for Taylor diagrams: one like with direct statistics, one with MV2 variables as arguments.

dtaylor(stats, stdref=None, labels=None, colors=None, **kwargs)[source]

Directly plot a Taylor diagram

Params:
  • stats: Statistics is the form [std, corr] or [[std1,corr1],[std2,corr2],...]
  • stdref: Standard deviation of reference
  • labels,optional: Label of the points. Obviously, if there are several points, there must have several labels. If None, it tries to get it from the long_name attribute. If False, it doesn’t display it.
  • reflabel,optional: Name of the reference label. It defaults to "Reference".
  • stdref, optional: Standard deviation of the reference used either when normalizing statistics or to plot the reference arc and point. All statistics can have a different reference standard deviation; in this case, statistics are normalized (normalize is set to True).
  • addref,optional: Add the reference arc and point to the plot.
  • normalize, optional: Force the normalization of statistics (standard deviations).
  • negative,optional: Force plot of negative correlations.
  • legend, optional: Add the legend.
  • size,optional: Size(s) of the markers in points.
  • colors,optional: Color of the points. It can be a list to set a different color for each pair.
  • cmap, optional: Colormap use when colors is a numeric array.
  • label_colors,optional: Color of the labels. If "same", color is taken from colors.
  • label_<keyword>,optional: <keyword> is passed to text() for plotting the labels.
  • symbols,optional: Symbols for the points (default to "o").
  • point_<keyword>,optional: <keyword> is passed to plot() (scatter() if scatter is True) or for plotting the points.
  • reflabel,optional: Label of the reference.
  • refcolor,optional: Color of the reference.
  • title,optional: A string for the general title.
  • scatter, optional: Use matplotlib.pyplot.scatter() to improve plot efficiency when the number of points is huge. Labels are not plotted in this mode.
  • savefig,optional: Save figure to savefig.
  • savefig_<keyword>,optional: <keyword> is used for saving figure.
  • savefigs,optional: Save figure to savefig using savefigs().
  • savefigs_<keyword>,optional: <keyword> is used for saving figure using savefigs().
ellipsis(xpos, ypos, eAXIS, eaxis=None, rotation=0, sign=0, np=100, gobj=None, m=None, scale=1.0, fill=False, sign_usearrow=True, axes=True, sign_usecolor=False, sign_usewidth=False, units=None, key=True, key_align='top', key_orientation='tangential', glow=False, shadow=False, key_position=1.15, key_format='%(value)g %(units)s', **kwargs)[source]

Create a dicretized ellipsis

  • xpos: X position of the ellipsis.
  • ypos: Y //
  • eAXIS: Length of grand axis
  • eaxis: Length of little axis [default: eAXIS]
  • rotation: Rotation angle in degrees of grand axis from X axis [default: 0.]
  • sign: Indicate a direction of evolution along the ellipsis using a variable line width and/or color [default: 0]. If 0, nothing is done. If positive or negative, it defines the direction relative the trigonometric convention.
  • sign_usearrow: Use an arrow to indicate sign [default: True]
  • sign_usewidth: Use width variation to indicate sign [default: False]
  • sign_usecolor: Use color variation (from grey to default color) to indicate sign [default: False]
  • scale: Scale factor to apply to grand and little axes [default: 1.]
  • np: Number of discretized segments [default: 100]
  • gobj: Graphical object on which to plot the ellipsis (can be a Basemap object) [default: ~matplotlib.pyplot.gca()]. If map object, eAXIS and eaxis are supposed to be in kilometers.
get_cls(n, colors=['k', 'b', 'g', 'r', 'c', 'm', 'y'], linestyles=['-', '--', '-.', ':'])[source]

Get a list of string argument for plot() to specify the color and the linestyle

  • n: Length of the list
  • colors: Colors on which to cycle
  • linestyles: Linestyles on which to cycle
get_locator_from_units(locator, *args, **kwargs)[source]
get_major_locator(xy, real=False, **kwargs)[source]
get_minor_locator(xy, **kwargs)[source]
get_quiverkey_value(data, mode=80)[source]

Get a decent value for a quiver key

gobjs(*args, **kwargs)[source]

Store and retreive graphic objects of the current axes

hldays(color='.95', y=False, tmin=None, tmax=None, fig=None, axes=None, **kwargs)[source]

Highlight different days with a different background color

Params:
  • color: Background color.
  • y: Work on Y axis.
  • Other keyparam are passed to axhspan() or axvspan().
hlitvs(color='.95', axis='x', units='ticks', axes=None, maxticks=10, **kwargs)[source]

Highlight intervals between ticks

Params:
  • color: Background color.

  • axis: Matplotlib axis or ‘x’/’y’.

  • units, optional: Interval types

    • “ticks”: Use axis ticks.
    • A list or array: use it as ticks.
    • “auto”: Estimate ticks using AutoLocator.
    • “date” or “time”: Same but using AutoDateLocator2.
    • A time string like “day” for using DayLocator.
    • A locator.
  • Other keyparam are passed to axhspan() or axvspan().

hov2(data, order=None, contour=True, fill='pcolor', levels=None, colorbar=True, title=None, xaxis=None, yaxis=None, **kwargs)[source]

Plot data as a Hovmoller diagram (2D with one axis as time) and get a Nov object.

Example:
>>> hov2(temp[:,-1,:,3], order='ty') # Force time as Y axis
>>> h = hov2(ssh, show=False)
Data params:
  • data: A single or a tuple or 2D MV2 arrays.

    • Single variable: Plot 2D scalar field with contours, filled contours, pcolor or image.
    • 2-tuple (U,V): Plot arrows.
    • 3-tuple (M,U,V): Plot both scalar field M and arrows.
  • order, optional: A string of length 2 that specify the physical type of plot axes. The first char refers to the Y axis, and the second to the X axis. It must contain one of the following characters:

    • x: longitude
    • y: latitude
    • z: level
    • t: time
    • -: any of the latters
    • d: data

    If char is upper-cased, its type is mandatory and must be found in input cdms2 variables. It defines the order attribute.

  • x/yaxis, optional: 1D or 2D array or axes to use for axis, instead of internal axes of input variables.

  • long_name, optional: Force the long_name attribute used in title. See also param x/ylong_name.

  • units, optional: Force the units attribute used in labels (label, xlabel or ylabel).

2D plot params:
  • contour, optional: Plot line contours.

  • contour_<param>, optional: <param> is passed to contour().

  • contour_<param>, optional: <param> is passed to contour().

  • fill, optional: Type filling. It defaults to fill option of the [vacumm.misc.plot] section of the configuration (see edit_config()).

  • nofill, optional: Implies fill=0.

  • levels, optional: Levels to use for contours or colorbar ticks. “They can be specified as a single value, a list or array, or ” “as a tuple used as argument to numpy.arange(). It sets the attribute levels.

  • levels_<param>, optional: Passed to get_levels() to tune levels.

  • levels_mode, optional: Mode of computing levels if needed. It can be specified at initialisation with attribute levels_mode. If not specified, it it taken from the config section [vacumm.misc.plot] and config option levels_mode.

    • "symetric": Min and max are set opposite.
    • "positive": Min is set to 0.
    • "negative": Max is set to 0.
    • "auto": If abs(min) and abs(max) are close, "symetric" is assumed. If min and max are > 0, "positive" is assumed, and the reverse for "negative".
  • keepminmax, optional: It can be specified at initialisation with attribute keepminmax. If not specified, it it taken from the config section [vacumm.misc.plot] and config option keepminmax. If False or 0, adjust vmin and vmax to first and last values of levels; if 1, do not change vmin, vmax and levels if 2, adjust first and last values of levels or vmin, vmax. It sets the attribute cmap.

  • nmax_levels, optional: Maximal number of levels when levels are computed automatically. It sets the attribute nmax_levels.

  • nmax, optional: Same as nmax_levels. It sets the attribute keepminmax.

  • cmap, optional: Colormap name (see vacumm.misc.color.get_cmap()). If not specified, it is taken from config section [vacumm.misc.plot] and config option cmap, as a string that defaults to magic.

  • cmap_<param>, optional: Passed to get_cmap() to tune colormap.

  • alpha, optional: Opacity.

  • fill_<param>: <param> is passed to the corresponding plot function.

  • shading, optional: Shading with pcolor().

  • extend, optional: Let’s contourf() add contours to cover all data range.

  • linewidths, optional: Contour linewidths.

  • clabel, optional: Add contour labels with clabel(). If not specified, it is taken from config section [vacumm.misc.plot] and config option clabel.

  • clabel_<param>, optional: <param> is passed to clabel()..

  • quiver_<param>, optional: <param> is passed to quiver().

  • quiver_norm,optional: Normalize/colorize arrows

    • 0 or None: No normalization, no colorization (default)
    • 1: Normalization, no colorization.
    • 2: Normalization, colorization.
    • 3: No normalization, colorization.
  • quiver_samp, optional: Horizontal sampling of arrows (in both directions) [default: 1]

  • quiver_x/ysamp, optional: Sampling along X/Y [default: quiver_samp]

  • quiver_res, optional: Horizontal resolution of arrows (in both directions) for undersampling [default: None]

    If 'auto', resolution is computed so as to have at max quiver_nauto arrow in along an axis. If it is a complex type, its imaginary part set the quiver_nauto parameter and quiver_res is set to 'auto'.

  • quiver_x/yres, optional: Same along X/Y [default: quiver_res]

  • quiver_relres, optional: Relative resolution (in both directions).

    • If > 0, = mean(res)*relres.
    • If < -1, = min(res)*abs(relres).
    • If < 0 and > -1, = max(res)*abs(relres)
  • quiver_x/yrelres, optional: Same along X/Y [default: quiver_relres]

  • quiverkey, optional: Add key to scale arrows.

  • quiverkey_pos, optional: Position of key for arrow .

  • quiverkey_text, optional: Text or format with variables ‘value’ and ‘units’.

  • quiverkey_value, optional: Numeric value for key (used by text).

  • quiverkey_units, optional: Units for key (used by text).

  • quiverkey_latex_units, optional: Interpret units using latex.

  • quiverkey_<param>, optional: <param> is passed to quiverkey().

  • colorbar, optional: Plot the colorbar.

  • colorbar_<param>, optional: <param> is passed to colorbar().

Plot initialization:
 
  • fig, optional: Figure number.
  • figsize, optional: Initialize the figure with this size.
  • subplot, optional: Call to subplot() to create axes.
  • subplots_adjust, optional: Dictionary sent to subplots_adjust(). You can also use keyparams ‘left’, ‘right’, ‘top’, ‘bottom’, ‘wspace’, ‘hspace’!
  • top/bottom/left/right/wspace/hspace, optional: Override subplots_adjust.
  • axes, optional: Use this axes object.
  • axes_<param>, optional: <param> is passed to axes().
  • axes_rect, optional: [left, bottom, width, height] in normalized (0,1) units to create axes using axes().
  • bgcolor, optional: Background axis color.
  • twin, optional: Use "x" or "y" or "xy" to make a copy of current X or Y axes (see matplotlib.pyplot.twinx()). You can also provide a dictionary : twin=dict(x=axes1, y=axes2).
  • noframe, optional: Suppress plot frames.
  • fullscreen, optional: Plot in full screen mode (thus, noframe==True).
Plot finalization:
 
  • title, optional: Force the title of the plot by setting title
  • title_<param>: <param> is passed to title()
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/y/vlim, optional: Force min/max of X or Y axis with (min,max)` like argument.
  • x/y/vminmax, optional: Minimal max value -> use this value if max is too low.
  • x/y/vmaxmin, optional: Maximal min value.
  • x/ymasked, optional: Force the plot to fit all data positions along X and/or Y, even if data is missing, by setting attributes xmasked, ymasked or xymasked.
  • x/ylong_name, optional: Same as long_name but for X and Y axes (xlong_name or ylong_name). It refers only to axes for 2D plots, and potentially to data for 1D plots.
  • x/yunits, optional: Same as units but for X and Y axes (xunits or yunits). It refers only to axes for 2D plots, and potentially to data for 1D plots. See also param x/yunits.
  • x/ylabel, optional: Force label used for X and Y axes by setting attributes xlabel or ylabel.
  • x/yticks, optional: Position of ticks.
  • x/yticklabels, optional: Label of ticks.
  • x/y/vskip, optional: Skip axis formating.
  • x/yhide, optional: Hide labels.
  • grid: Plot the grid [default: True]
  • grid_<param>: <param> is passed to grid()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • figtext: figtext Add text at a specified position on the figure. Example: figtext=[0,0,’text’] add a ‘text’ at the lower left corner, or simply figtext=’text’.
  • figtext_<param>: <param> is passed to figtext()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • key: Add a key (like ‘a)’) to the axes using add_key if different from None [default: None]
  • key_<param>: <param> is passed to add_key()
  • anchor: Anchor of the axes (useful when resizing) in [‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, ‘N’, ‘NW’, ‘W’].
  • autoresize: Auto resize the figure according axes (1 or True), axes+margins (2). If 0 or False, not resized [default: False=2].
  • savefig: Save the figure to this file.
  • savefig_verbose, optional: Informs about file name when written.
  • savefig_<param>: <param> is passed to method savefig() and finally to the matplotlib function savefig().
  • savefigs: Save the figure into multiple formats using savefigs() and ‘savefigs’ as the prefix to the files.
  • savefigs_<param>: <param> is passed to savefigs()
  • show: Display the figure [default: True]
  • close: Close the figure at the end [default: False]
More:
linestyles = ['-', '--', '-.', ':']

Useful linestyles list

make_movie(fig_pattern, outfile, delay=1, clean=False, verbose=False, windows=True)[source]

Make a movie from a series of figures

  • fig_pattern Unix-like file pattern to select png figures.
  • outfile: Output file.
  • delay*: Delay in seconds between two frames.
  • windows: When output is a movie, choose basic mpeg for windows instead of mpeg4 codec.
  • clean: If True, remove figures once the movies os created.
Usage:
>>> make_movie('/home/toto/fig*.png', 'movie.mpg', delay=.5, clean=True)
map2(data=None, proj='cyl', res='auto', lon=None, lat=None, contour=True, fill='pcolor', levels=None, colorbar=True, xaxis=None, yaxis=None, title=None, savefig=None, show=True, **kwargs)[source]

Plot an empty map or data on a map and return a Map object with properties also from Plot, Plot2D, ScalarMappable and QuiverKey.

Example:
>>> map2(xe, resolution='i')
>>> map2(lon=(-10,0), lat=(45,55), drawrivers=True, drawrivers_color='b')
>>> m = map(bathy, show=False)
>>> m.add_place(x, y, 'Brest')
>>> m.show()
Data params:
  • data: A single or a tuple or 2D MV2 arrays.
    • Single variable: Plot 2D scalar field with contours, filled contours, pcolor or image.
    • 2-tuple (U,V): Plot arrows.
    • 3-tuple (M,U,V): Plot both scalar field M and arrows.
  • lon, optional: Longitude interval.
  • lat, optional: Latitude interval.
  • x/yaxis, optional: 1D or 2D array or axes to use for axis, instead of internal axes of input variables.
  • long_name, optional: Force the long_name attribute used in title. See also param x/ylong_name.
  • units, optional: Force the units attribute used in labels (label, xlabel or ylabel).
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
Map params:
  • projection: Map projection, like “merc”. See Basemap for a list of possible projections.
  • resolution: GSHHS resolution of shoreline or ‘s’ for Histolitt (SHOM).
  • "c": Crude.
  • "l": Low.
  • "i": Intermediate.
  • "h": High.
  • "f": Full.
  • "s": Histolittfor the french coast (from a shapefile file automatically downloaded once the license is accepted).
  • map_update: Force the update of the map latter by post_plot(), setting map_update.
  • nocache: Management of cached maps.
  • zoom: Zoom on map bounds before creating it.
  • fillcontinents: Fill continents with color land_color using method fillcontinents().
  • fillcontinents_<param>: Pass <param> to the method.
  • land_color: Fill color.
  • drawrivers: Draw rivers on the map using method drawrivers().
  • drawrivers_<param>: Pass <param> to the method.
  • meridians: Meridians to plot.
  • drawmeridians: Display or hide medidians and associated labels using method drawmeridians().
  • drawmeridians_<param>: Pass <param> to the method.
  • parallels: Parallels to plot.
  • drawparallels: Display or hide parallels and associated labels using method drawparallels().
  • drawparallels_<param>: Pass <param> to the method.
  • meridional/zonal_labels: Display or hide meridional/zonal labels. meridional/zonal_labels=False is equivalent to y/xhide=True.
  • fullscreen: Full screen mode -> no colorbar and no labels.
  • mapscale: Add a map scale using add_mapscale().
  • mapscale_<param>: Pass <param> to the add_mapscale() method.
  • compass: Add a compass using add_compass().
  • compass_<param>: Pass <param> to the add_compass() method.
  • mscp: Add a mapscale AND a compass using add_mscp().
  • mscp_<param>: Pass <param> to the add_mscp() method.
2D plot params:
  • contour, optional: Plot line contours.

  • contour_<param>, optional: <param> is passed to contour().

  • contour_<param>, optional: <param> is passed to contour().

  • fill, optional: Type filling. It defaults to fill option of the [vacumm.misc.plot] section of the configuration (see edit_config()).

  • nofill, optional: Implies fill=0.

  • levels, optional: Levels to use for contours or colorbar ticks. “They can be specified as a single value, a list or array, or ” “as a tuple used as argument to numpy.arange(). It sets the attribute levels.

  • levels_<param>, optional: Passed to get_levels() to tune levels.

  • levels_mode, optional: Mode of computing levels if needed. It can be specified at initialisation with attribute levels_mode. If not specified, it it taken from the config section [vacumm.misc.plot] and config option levels_mode.

    • "symetric": Min and max are set opposite.
    • "positive": Min is set to 0.
    • "negative": Max is set to 0.
    • "auto": If abs(min) and abs(max) are close, "symetric" is assumed. If min and max are > 0, "positive" is assumed, and the reverse for "negative".
  • keepminmax, optional: It can be specified at initialisation with attribute keepminmax. If not specified, it it taken from the config section [vacumm.misc.plot] and config option keepminmax. If False or 0, adjust vmin and vmax to first and last values of levels; if 1, do not change vmin, vmax and levels if 2, adjust first and last values of levels or vmin, vmax. It sets the attribute cmap.

  • nmax_levels, optional: Maximal number of levels when levels are computed automatically. It sets the attribute nmax_levels.

  • nmax, optional: Same as nmax_levels. It sets the attribute keepminmax.

  • cmap, optional: Colormap name (see vacumm.misc.color.get_cmap()). If not specified, it is taken from config section [vacumm.misc.plot] and config option cmap, as a string that defaults to magic.

  • cmap_<param>, optional: Passed to get_cmap() to tune colormap.

  • alpha, optional: Opacity.

  • fill_<param>: <param> is passed to the corresponding plot function.

  • shading, optional: Shading with pcolor().

  • extend, optional: Let’s contourf() add contours to cover all data range.

  • linewidths, optional: Contour linewidths.

  • clabel, optional: Add contour labels with clabel(). If not specified, it is taken from config section [vacumm.misc.plot] and config option clabel.

  • clabel_<param>, optional: <param> is passed to clabel()..

  • quiver_<param>, optional: <param> is passed to quiver().

  • quiver_norm,optional: Normalize/colorize arrows

    • 0 or None: No normalization, no colorization (default)
    • 1: Normalization, no colorization.
    • 2: Normalization, colorization.
    • 3: No normalization, colorization.
  • quiver_samp, optional: Horizontal sampling of arrows (in both directions) [default: 1]

  • quiver_x/ysamp, optional: Sampling along X/Y [default: quiver_samp]

  • quiver_res, optional: Horizontal resolution of arrows (in both directions) for undersampling [default: None]

    If 'auto', resolution is computed so as to have at max quiver_nauto arrow in along an axis. If it is a complex type, its imaginary part set the quiver_nauto parameter and quiver_res is set to 'auto'.

  • quiver_x/yres, optional: Same along X/Y [default: quiver_res]

  • quiver_relres, optional: Relative resolution (in both directions).

    • If > 0, = mean(res)*relres.
    • If < -1, = min(res)*abs(relres).
    • If < 0 and > -1, = max(res)*abs(relres)
  • quiver_x/yrelres, optional: Same along X/Y [default: quiver_relres]

  • quiverkey, optional: Add key to scale arrows.

  • quiverkey_pos, optional: Position of key for arrow .

  • quiverkey_text, optional: Text or format with variables ‘value’ and ‘units’.

  • quiverkey_value, optional: Numeric value for key (used by text).

  • quiverkey_units, optional: Units for key (used by text).

  • quiverkey_latex_units, optional: Interpret units using latex.

  • quiverkey_<param>, optional: <param> is passed to quiverkey().

  • colorbar, optional: Plot the colorbar.

  • colorbar_<param>, optional: <param> is passed to colorbar().

Plot initialization:
 
  • fig, optional: Figure number.
  • figsize, optional: Initialize the figure with this size.
  • subplot, optional: Call to subplot() to create axes.
  • subplots_adjust, optional: Dictionary sent to subplots_adjust(). You can also use keyparams ‘left’, ‘right’, ‘top’, ‘bottom’, ‘wspace’, ‘hspace’!
  • top/bottom/left/right/wspace/hspace, optional: Override subplots_adjust.
  • axes, optional: Use this axes object.
  • axes_<param>, optional: <param> is passed to axes().
  • axes_rect, optional: [left, bottom, width, height] in normalized (0,1) units to create axes using axes().
  • bgcolor, optional: Background axis color.
  • twin, optional: Use "x" or "y" or "xy" to make a copy of current X or Y axes (see matplotlib.pyplot.twinx()). You can also provide a dictionary : twin=dict(x=axes1, y=axes2).
  • noframe, optional: Suppress plot frames.
  • fullscreen, optional: Plot in full screen mode (thus, noframe==True).
Plot finalization:
 
  • title, optional: Force the title of the plot by setting title
  • title_<param>: <param> is passed to title()
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/y/vlim, optional: Force min/max of X or Y axis with (min,max)` like argument.
  • x/y/vminmax, optional: Minimal max value -> use this value if max is too low.
  • x/y/vmaxmin, optional: Maximal min value.
  • x/ymasked, optional: Force the plot to fit all data positions along X and/or Y, even if data is missing, by setting attributes xmasked, ymasked or xymasked.
  • x/ylong_name, optional: Same as long_name but for X and Y axes (xlong_name or ylong_name). It refers only to axes for 2D plots, and potentially to data for 1D plots.
  • x/yunits, optional: Same as units but for X and Y axes (xunits or yunits). It refers only to axes for 2D plots, and potentially to data for 1D plots. See also param x/yunits.
  • x/ylabel, optional: Force label used for X and Y axes by setting attributes xlabel or ylabel.
  • x/yticks, optional: Position of ticks.
  • x/yticklabels, optional: Label of ticks.
  • x/y/vskip, optional: Skip axis formating.
  • x/yhide, optional: Hide labels.
  • grid: Plot the grid [default: True]
  • grid_<param>: <param> is passed to grid()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • figtext: figtext Add text at a specified position on the figure. Example: figtext=[0,0,’text’] add a ‘text’ at the lower left corner, or simply figtext=’text’.
  • figtext_<param>: <param> is passed to figtext()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • key: Add a key (like ‘a)’) to the axes using add_key if different from None [default: None]
  • key_<param>: <param> is passed to add_key()
  • anchor: Anchor of the axes (useful when resizing) in [‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, ‘N’, ‘NW’, ‘W’].
  • autoresize: Auto resize the figure according axes (1 or True), axes+margins (2). If 0 or False, not resized [default: False=2].
  • savefig: Save the figure to this file.
  • savefig_verbose, optional: Informs about file name when written.
  • savefig_<param>: <param> is passed to method savefig() and finally to the matplotlib function savefig().
  • savefigs: Save the figure into multiple formats using savefigs() and ‘savefigs’ as the prefix to the files.
  • savefigs_<param>: <param> is passed to savefigs()
  • show: Display the figure [default: True]
  • close: Close the figure at the end [default: False]
Other params:
  • Specific params: see Map.
  • Specific plot initialization params: see pre_plot.
  • Specific plot params: see plot.
  • Specific plot finalization params: see post_plot.
  • Other generic params: see Plot.
markers = ['o', 'v', '^', '<', '>', '8', 's', 'p', 'h', '+', 'x', 'd']

Useful markers list

minimap(gg, bbox=[0.85, 0.85, 0.14, 0.14], zoom=1.0, xmargin=None, ymargin=None, lon=None, lat=None, square=False, bgcolor=(0, 0.8, 1.0), fig=None, alpha=1, **kwargs)[source]

Create a minimap with map2()

A minimap is small and generally in a corner of the figure, and used to show simple geographic information.

Examples:
>>> minimap(((lonmin,lonmax),(latmin,latmax))).add_point(-5,48)
>>> minimap(sst.getGrid())
>>> m = minimap(sst)
>>> m.add_point(lon, lat)
Return:

A Map object.

plot2d(data, contour=True, fill='pcolor', levels=None, colorbar=True, xaxis=None, yaxis=None, title=None, savefig=None, show=True, **kwargs)[source]

Generic plot of a 2D variable and return a Plot2D object with properties also from Plot, ScalarMappable and QuiverKey.

Example:
>>> plot2d(xe)
Data params:
  • data: A single or a tuple or 2D MV2 arrays.
    • Single variable: Plot 2D scalar field with contours, filled contours, pcolor or image.
    • 2-tuple (U,V): Plot arrows.
    • 3-tuple (M,U,V): Plot both scalar field M and arrows.
  • lon, optional: Longitude interval.
  • lat, optional: Latitude interval.
  • x/yaxis, optional: 1D or 2D array or axes to use for axis, instead of internal axes of input variables.
  • long_name, optional: Force the long_name attribute used in title. See also param x/ylong_name.
  • units, optional: Force the units attribute used in labels (label, xlabel or ylabel).
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
2D plot params:
  • contour, optional: Plot line contours.

  • contour_<param>, optional: <param> is passed to contour().

  • contour_<param>, optional: <param> is passed to contour().

  • fill, optional: Type filling. It defaults to fill option of the [vacumm.misc.plot] section of the configuration (see edit_config()).

  • nofill, optional: Implies fill=0.

  • levels, optional: Levels to use for contours or colorbar ticks. “They can be specified as a single value, a list or array, or ” “as a tuple used as argument to numpy.arange(). It sets the attribute levels.

  • levels_<param>, optional: Passed to get_levels() to tune levels.

  • levels_mode, optional: Mode of computing levels if needed. It can be specified at initialisation with attribute levels_mode. If not specified, it it taken from the config section [vacumm.misc.plot] and config option levels_mode.

    • "symetric": Min and max are set opposite.
    • "positive": Min is set to 0.
    • "negative": Max is set to 0.
    • "auto": If abs(min) and abs(max) are close, "symetric" is assumed. If min and max are > 0, "positive" is assumed, and the reverse for "negative".
  • keepminmax, optional: It can be specified at initialisation with attribute keepminmax. If not specified, it it taken from the config section [vacumm.misc.plot] and config option keepminmax. If False or 0, adjust vmin and vmax to first and last values of levels; if 1, do not change vmin, vmax and levels if 2, adjust first and last values of levels or vmin, vmax. It sets the attribute cmap.

  • nmax_levels, optional: Maximal number of levels when levels are computed automatically. It sets the attribute nmax_levels.

  • nmax, optional: Same as nmax_levels. It sets the attribute keepminmax.

  • cmap, optional: Colormap name (see vacumm.misc.color.get_cmap()). If not specified, it is taken from config section [vacumm.misc.plot] and config option cmap, as a string that defaults to magic.

  • cmap_<param>, optional: Passed to get_cmap() to tune colormap.

  • alpha, optional: Opacity.

  • fill_<param>: <param> is passed to the corresponding plot function.

  • shading, optional: Shading with pcolor().

  • extend, optional: Let’s contourf() add contours to cover all data range.

  • linewidths, optional: Contour linewidths.

  • clabel, optional: Add contour labels with clabel(). If not specified, it is taken from config section [vacumm.misc.plot] and config option clabel.

  • clabel_<param>, optional: <param> is passed to clabel()..

  • quiver_<param>, optional: <param> is passed to quiver().

  • quiver_norm,optional: Normalize/colorize arrows

    • 0 or None: No normalization, no colorization (default)
    • 1: Normalization, no colorization.
    • 2: Normalization, colorization.
    • 3: No normalization, colorization.
  • quiver_samp, optional: Horizontal sampling of arrows (in both directions) [default: 1]

  • quiver_x/ysamp, optional: Sampling along X/Y [default: quiver_samp]

  • quiver_res, optional: Horizontal resolution of arrows (in both directions) for undersampling [default: None]

    If 'auto', resolution is computed so as to have at max quiver_nauto arrow in along an axis. If it is a complex type, its imaginary part set the quiver_nauto parameter and quiver_res is set to 'auto'.

  • quiver_x/yres, optional: Same along X/Y [default: quiver_res]

  • quiver_relres, optional: Relative resolution (in both directions).

    • If > 0, = mean(res)*relres.
    • If < -1, = min(res)*abs(relres).
    • If < 0 and > -1, = max(res)*abs(relres)
  • quiver_x/yrelres, optional: Same along X/Y [default: quiver_relres]

  • quiverkey, optional: Add key to scale arrows.

  • quiverkey_pos, optional: Position of key for arrow .

  • quiverkey_text, optional: Text or format with variables ‘value’ and ‘units’.

  • quiverkey_value, optional: Numeric value for key (used by text).

  • quiverkey_units, optional: Units for key (used by text).

  • quiverkey_latex_units, optional: Interpret units using latex.

  • quiverkey_<param>, optional: <param> is passed to quiverkey().

  • colorbar, optional: Plot the colorbar.

  • colorbar_<param>, optional: <param> is passed to colorbar().

Plot initialization:
 
  • fig, optional: Figure number.
  • figsize, optional: Initialize the figure with this size.
  • subplot, optional: Call to subplot() to create axes.
  • subplots_adjust, optional: Dictionary sent to subplots_adjust(). You can also use keyparams ‘left’, ‘right’, ‘top’, ‘bottom’, ‘wspace’, ‘hspace’!
  • top/bottom/left/right/wspace/hspace, optional: Override subplots_adjust.
  • axes, optional: Use this axes object.
  • axes_<param>, optional: <param> is passed to axes().
  • axes_rect, optional: [left, bottom, width, height] in normalized (0,1) units to create axes using axes().
  • bgcolor, optional: Background axis color.
  • twin, optional: Use "x" or "y" or "xy" to make a copy of current X or Y axes (see matplotlib.pyplot.twinx()). You can also provide a dictionary : twin=dict(x=axes1, y=axes2).
  • noframe, optional: Suppress plot frames.
  • fullscreen, optional: Plot in full screen mode (thus, noframe==True).
Plot finalization:
 
  • title, optional: Force the title of the plot by setting title
  • title_<param>: <param> is passed to title()
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/y/vlim, optional: Force min/max of X or Y axis with (min,max)` like argument.
  • x/y/vminmax, optional: Minimal max value -> use this value if max is too low.
  • x/y/vmaxmin, optional: Maximal min value.
  • x/ymasked, optional: Force the plot to fit all data positions along X and/or Y, even if data is missing, by setting attributes xmasked, ymasked or xymasked.
  • x/ylong_name, optional: Same as long_name but for X and Y axes (xlong_name or ylong_name). It refers only to axes for 2D plots, and potentially to data for 1D plots.
  • x/yunits, optional: Same as units but for X and Y axes (xunits or yunits). It refers only to axes for 2D plots, and potentially to data for 1D plots. See also param x/yunits.
  • x/ylabel, optional: Force label used for X and Y axes by setting attributes xlabel or ylabel.
  • x/yticks, optional: Position of ticks.
  • x/yticklabels, optional: Label of ticks.
  • x/y/vskip, optional: Skip axis formating.
  • x/yhide, optional: Hide labels.
  • grid: Plot the grid [default: True]
  • grid_<param>: <param> is passed to grid()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • figtext: figtext Add text at a specified position on the figure. Example: figtext=[0,0,’text’] add a ‘text’ at the lower left corner, or simply figtext=’text’.
  • figtext_<param>: <param> is passed to figtext()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • key: Add a key (like ‘a)’) to the axes using add_key if different from None [default: None]
  • key_<param>: <param> is passed to add_key()
  • anchor: Anchor of the axes (useful when resizing) in [‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, ‘N’, ‘NW’, ‘W’].
  • autoresize: Auto resize the figure according axes (1 or True), axes+margins (2). If 0 or False, not resized [default: False=2].
  • savefig: Save the figure to this file.
  • savefig_verbose, optional: Informs about file name when written.
  • savefig_<param>: <param> is passed to method savefig() and finally to the matplotlib function savefig().
  • savefigs: Save the figure into multiple formats using savefigs() and ‘savefigs’ as the prefix to the files.
  • savefigs_<param>: <param> is passed to savefigs()
  • show: Display the figure [default: True]
  • close: Close the figure at the end [default: False]
Other params:
  • Specific params: see Plot2D.
  • Specific plot initialization params: see pre_plot.
  • Specific plot params: see plot.
  • Specific plot finalization params: see post_plot.
  • Other generic params: see Plot.
rankhist(obs, ens, title='Rank histogram', bins=None, **kwargs)[source]

Plot rank histogram

The rank is computed using ensrank(). It may vary from 0 to nens.

  • obs, (…): Observations or rank
  • ens, (nens,…): Ensemble or nens
rotate_tick_labels(angle, vertical=0, *args, **kwargs)[source]

Rotate labels along an axis

  • angle: Angle in degrees OR False.
  • vertical: On vertical axis if not 0 [default: 0]
  • Other arguments are passed to setp()
rotate_xlabels(angle, *args, **kwargs)[source]

Shortcut to xrotate()

rotate_ylabels(angle, *args, **kwargs)[source]

Shortcut to yrotate()

rshpere_wgs84 = (6378137.0, 6356752.3141)

WGS radius of earth

savefigs(basename, png=True, pdf=False, verbose=True, dpi=100, nodots=True, fig=None, **kwargs)[source]

Save a figure in multiple formats (optimized for sphinx doc generator)

  • basename: File name without suffix
  • png: If True, save to png format
  • pdf: If True, save to pdf format
  • verbose: If True, print file names that are created
  • Other keywords are passed to savefig()

Warning

Dots (‘.’) in figure name are converted to dashes (‘-‘) for compatilibity reasons with latex. It is optimized for the sphinx doc generator and may NOT BE SUITABLE FOR YOU. In this case, use savefig() instead.

scale_xlim(*args, **kwargs)[source]

Shortcut to xscale()

scale_ylim(*args, **kwargs)[source]

Shortcut to yscale()

scolorbar(*args, **kwargs)[source]

Shortcut to add_colorbar()

section2(data, contour=True, fill='pcolor', levels=None, colorbar=True, title=None, xaxis=None, yaxis=None, **kwargs)[source]

Plot geographical data as a vertical-horizontal section and return a Section object with properties also from Plot, Plot2D, ScalarMappable and QuiverKey.

Example:
>>> section2(temp[0,:, :,3])
Data params:
  • data: A single or a tuple or 2D MV2 arrays.
    • Single variable: Plot 2D scalar field with contours, filled contours, pcolor or image.
    • 2-tuple (U,V): Plot arrows.
    • 3-tuple (M,U,V): Plot both scalar field M and arrows.
  • x/yaxis, optional: 1D or 2D array or axes to use for axis, instead of internal axes of input variables.
  • long_name, optional: Force the long_name attribute used in title. See also param x/ylong_name.
  • units, optional: Force the units attribute used in labels (label, xlabel or ylabel).
2D plot params:
  • contour, optional: Plot line contours.

  • contour_<param>, optional: <param> is passed to contour().

  • contour_<param>, optional: <param> is passed to contour().

  • fill, optional: Type filling. It defaults to fill option of the [vacumm.misc.plot] section of the configuration (see edit_config()).

  • nofill, optional: Implies fill=0.

  • levels, optional: Levels to use for contours or colorbar ticks. “They can be specified as a single value, a list or array, or ” “as a tuple used as argument to numpy.arange(). It sets the attribute levels.

  • levels_<param>, optional: Passed to get_levels() to tune levels.

  • levels_mode, optional: Mode of computing levels if needed. It can be specified at initialisation with attribute levels_mode. If not specified, it it taken from the config section [vacumm.misc.plot] and config option levels_mode.

    • "symetric": Min and max are set opposite.
    • "positive": Min is set to 0.
    • "negative": Max is set to 0.
    • "auto": If abs(min) and abs(max) are close, "symetric" is assumed. If min and max are > 0, "positive" is assumed, and the reverse for "negative".
  • keepminmax, optional: It can be specified at initialisation with attribute keepminmax. If not specified, it it taken from the config section [vacumm.misc.plot] and config option keepminmax. If False or 0, adjust vmin and vmax to first and last values of levels; if 1, do not change vmin, vmax and levels if 2, adjust first and last values of levels or vmin, vmax. It sets the attribute cmap.

  • nmax_levels, optional: Maximal number of levels when levels are computed automatically. It sets the attribute nmax_levels.

  • nmax, optional: Same as nmax_levels. It sets the attribute keepminmax.

  • cmap, optional: Colormap name (see vacumm.misc.color.get_cmap()). If not specified, it is taken from config section [vacumm.misc.plot] and config option cmap, as a string that defaults to magic.

  • cmap_<param>, optional: Passed to get_cmap() to tune colormap.

  • alpha, optional: Opacity.

  • fill_<param>: <param> is passed to the corresponding plot function.

  • shading, optional: Shading with pcolor().

  • extend, optional: Let’s contourf() add contours to cover all data range.

  • linewidths, optional: Contour linewidths.

  • clabel, optional: Add contour labels with clabel(). If not specified, it is taken from config section [vacumm.misc.plot] and config option clabel.

  • clabel_<param>, optional: <param> is passed to clabel()..

  • quiver_<param>, optional: <param> is passed to quiver().

  • quiver_norm,optional: Normalize/colorize arrows

    • 0 or None: No normalization, no colorization (default)
    • 1: Normalization, no colorization.
    • 2: Normalization, colorization.
    • 3: No normalization, colorization.
  • quiver_samp, optional: Horizontal sampling of arrows (in both directions) [default: 1]

  • quiver_x/ysamp, optional: Sampling along X/Y [default: quiver_samp]

  • quiver_res, optional: Horizontal resolution of arrows (in both directions) for undersampling [default: None]

    If 'auto', resolution is computed so as to have at max quiver_nauto arrow in along an axis. If it is a complex type, its imaginary part set the quiver_nauto parameter and quiver_res is set to 'auto'.

  • quiver_x/yres, optional: Same along X/Y [default: quiver_res]

  • quiver_relres, optional: Relative resolution (in both directions).

    • If > 0, = mean(res)*relres.
    • If < -1, = min(res)*abs(relres).
    • If < 0 and > -1, = max(res)*abs(relres)
  • quiver_x/yrelres, optional: Same along X/Y [default: quiver_relres]

  • quiverkey, optional: Add key to scale arrows.

  • quiverkey_pos, optional: Position of key for arrow .

  • quiverkey_text, optional: Text or format with variables ‘value’ and ‘units’.

  • quiverkey_value, optional: Numeric value for key (used by text).

  • quiverkey_units, optional: Units for key (used by text).

  • quiverkey_latex_units, optional: Interpret units using latex.

  • quiverkey_<param>, optional: <param> is passed to quiverkey().

  • colorbar, optional: Plot the colorbar.

  • colorbar_<param>, optional: <param> is passed to colorbar().

Plot initialization:
 
  • fig, optional: Figure number.
  • figsize, optional: Initialize the figure with this size.
  • subplot, optional: Call to subplot() to create axes.
  • subplots_adjust, optional: Dictionary sent to subplots_adjust(). You can also use keyparams ‘left’, ‘right’, ‘top’, ‘bottom’, ‘wspace’, ‘hspace’!
  • top/bottom/left/right/wspace/hspace, optional: Override subplots_adjust.
  • axes, optional: Use this axes object.
  • axes_<param>, optional: <param> is passed to axes().
  • axes_rect, optional: [left, bottom, width, height] in normalized (0,1) units to create axes using axes().
  • bgcolor, optional: Background axis color.
  • twin, optional: Use "x" or "y" or "xy" to make a copy of current X or Y axes (see matplotlib.pyplot.twinx()). You can also provide a dictionary : twin=dict(x=axes1, y=axes2).
  • noframe, optional: Suppress plot frames.
  • fullscreen, optional: Plot in full screen mode (thus, noframe==True).
Plot finalization:
 
  • title, optional: Force the title of the plot by setting title
  • title_<param>: <param> is passed to title()
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/y/vlim, optional: Force min/max of X or Y axis with (min,max)` like argument.
  • x/y/vminmax, optional: Minimal max value -> use this value if max is too low.
  • x/y/vmaxmin, optional: Maximal min value.
  • x/ymasked, optional: Force the plot to fit all data positions along X and/or Y, even if data is missing, by setting attributes xmasked, ymasked or xymasked.
  • x/ylong_name, optional: Same as long_name but for X and Y axes (xlong_name or ylong_name). It refers only to axes for 2D plots, and potentially to data for 1D plots.
  • x/yunits, optional: Same as units but for X and Y axes (xunits or yunits). It refers only to axes for 2D plots, and potentially to data for 1D plots. See also param x/yunits.
  • x/ylabel, optional: Force label used for X and Y axes by setting attributes xlabel or ylabel.
  • x/yticks, optional: Position of ticks.
  • x/yticklabels, optional: Label of ticks.
  • x/y/vskip, optional: Skip axis formating.
  • x/yhide, optional: Hide labels.
  • grid: Plot the grid [default: True]
  • grid_<param>: <param> is passed to grid()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • figtext: figtext Add text at a specified position on the figure. Example: figtext=[0,0,’text’] add a ‘text’ at the lower left corner, or simply figtext=’text’.
  • figtext_<param>: <param> is passed to figtext()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • key: Add a key (like ‘a)’) to the axes using add_key if different from None [default: None]
  • key_<param>: <param> is passed to add_key()
  • anchor: Anchor of the axes (useful when resizing) in [‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, ‘N’, ‘NW’, ‘W’].
  • autoresize: Auto resize the figure according axes (1 or True), axes+margins (2). If 0 or False, not resized [default: False=2].
  • savefig: Save the figure to this file.
  • savefig_verbose, optional: Informs about file name when written.
  • savefig_<param>: <param> is passed to method savefig() and finally to the matplotlib function savefig().
  • savefigs: Save the figure into multiple formats using savefigs() and ‘savefigs’ as the prefix to the files.
  • savefigs_<param>: <param> is passed to savefigs()
  • show: Display the figure [default: True]
  • close: Close the figure at the end [default: False]
More:
set_major_locator(xy, locator, **kwargs)[source]
set_minor_locator(xy, locator, **kwargs)[source]
stick2(udata, vdata, polar=False, degrees=True, mod=False, pos=None, width=None, scale=None, color='k', line=True, levels=None, cmap=None, shadow=False, **kwargs)[source]

Plot data as a stick plot and return a Stick object with properties also from Plot, Plot1D, Curve, ScalarMappable and QuiverKey.

Example:
>>> stick2(u, v, color='mod', vmax=10., quiver_scale=50., mod=True)
>>> stick2(r, a, polar=True, degrees=False, quiverkey_value=5)
Data params:
  • udata: X or radial component of arrows.
  • vdata: Y or directional component of arrows.
  • polar, optional: Consider polar coordinates: (u, v) -> (rho, theta)
  • degrees, optional: If True (default), trat theta as degrees, else radians.
  • vertical, optional: Plot vertically.
  • axis, optional: Change plot axis.
  • long_name, optional: Force the long_name attribute used in title. See also param x/ylong_name.
  • units, optional: Force the units attribute used in labels (label, xlabel or ylabel).
Stick params:
  • pos, optional: Position of the arrow tails. It defaults to the middle of the appropriate axis.
  • mod, optional: Plot the curve of the modulus.
  • mod_<param>*, optional: <param> is passed to Curve.plot() when plotting the modulus.
  • line, optional: Add a transversal line along the arrow tails.
  • alpha, optional: Opacity.
  • headwidth, optional: Head width of arrows (see quiver()).
  • headlength, optional: Head length of arrows (see quiver()).
  • headaxislength, optional: Length of arrow head on axis (see quiver()).
  • minlength, optional: See quiver().
  • minshaft, optional: See quiver().
  • cmap, optional: Colormap to use when color="mod".
  • cmap_<param>, optional: Passed to meth:~vacumm.misc.core_plot.ScalarMappable.get_cmap to tune colormap.
  • levels, optional: Levels of values to use when color="mod".
  • levels_<param>, optional: Passed to meth:~vacumm.misc.core_plot.ScalarMappable.get_levels to tune levels.
  • shadow, optional: Add a drop shadow.
  • shadow_<param>, optional: <param> is passed to add_shadow()
  • colorbar, optional: Plot the colorbar.
  • colorbar_<param>, optional: <param> is passed to colorbar().
  • quiverkey_pos, optional: Position of key for arrow .
  • quiverkey_text, optional: Text or format with variables ‘value’ and ‘units’.
  • quiverkey_value, optional: Numeric value for key (used by text).
  • quiverkey_units, optional: Units for key (used by text).
  • quiverkey_latex_units, optional: Interpret units using latex.
Plot initialization:
 
  • fig, optional: Figure number.
  • figsize, optional: Initialize the figure with this size.
  • subplot, optional: Call to subplot() to create axes.
  • subplots_adjust, optional: Dictionary sent to subplots_adjust(). You can also use keyparams ‘left’, ‘right’, ‘top’, ‘bottom’, ‘wspace’, ‘hspace’!
  • top/bottom/left/right/wspace/hspace, optional: Override subplots_adjust.
  • axes, optional: Use this axes object.
  • axes_<param>, optional: <param> is passed to axes().
  • axes_rect, optional: [left, bottom, width, height] in normalized (0,1) units to create axes using axes().
  • bgcolor, optional: Background axis color.
  • twin, optional: Use "x" or "y" or "xy" to make a copy of current X or Y axes (see matplotlib.pyplot.twinx()). You can also provide a dictionary : twin=dict(x=axes1, y=axes2).
  • noframe, optional: Suppress plot frames.
  • fullscreen, optional: Plot in full screen mode (thus, noframe==True).
  • cax, optional: Axes for the colorbar.
Plot finalization:
 
  • title, optional: Force the title of the plot by setting title
  • title_<param>: <param> is passed to title()
  • latex_units, optional: Interpret units with latex after defining the latex_units attribute. Alternatively, you can simply specify units enclosed with "$".
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/ymin/max, optional: Force min and max along X and Y by setting attributes xmin, xmax, ymin or ymax.
  • x/y/vlim, optional: Force min/max of X or Y axis with (min,max)` like argument.
  • x/y/vminmax, optional: Minimal max value -> use this value if max is too low.
  • x/y/vmaxmin, optional: Maximal min value.
  • x/ymasked, optional: Force the plot to fit all data positions along X and/or Y, even if data is missing, by setting attributes xmasked, ymasked or xymasked.
  • x/ylong_name, optional: Same as long_name but for X and Y axes (xlong_name or ylong_name). It refers only to axes for 2D plots, and potentially to data for 1D plots.
  • x/yunits, optional: Same as units but for X and Y axes (xunits or yunits). It refers only to axes for 2D plots, and potentially to data for 1D plots. See also param x/yunits.
  • x/ylabel, optional: Force label used for X and Y axes by setting attributes xlabel or ylabel.
  • x/yticks, optional: Position of ticks.
  • x/yticklabels, optional: Label of ticks.
  • x/y/vskip, optional: Skip axis formating.
  • x/yhide, optional: Hide labels.
  • grid: Plot the grid [default: True]
  • grid_<param>: <param> is passed to grid()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • figtext: figtext Add text at a specified position on the figure. Example: figtext=[0,0,’text’] add a ‘text’ at the lower left corner, or simply figtext=’text’.
  • figtext_<param>: <param> is passed to figtext()
  • legend, optional: Draw the legend using legend().
  • legend_<param>: <param> is passed to legend()
  • key: Add a key (like ‘a)’) to the axes using add_key if different from None [default: None]
  • key_<param>: <param> is passed to add_key()
  • anchor: Anchor of the axes (useful when resizing) in [‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, ‘N’, ‘NW’, ‘W’].
  • autoresize: Auto resize the figure according axes (1 or True), axes+margins (2). If 0 or False, not resized [default: False=2].
  • savefig: Save the figure to this file.
  • savefig_verbose, optional: Informs about file name when written.
  • savefig_<param>: <param> is passed to method savefig() and finally to the matplotlib function savefig().
  • savefigs: Save the figure into multiple formats using savefigs() and ‘savefigs’ as the prefix to the files.
  • savefigs_<param>: <param> is passed to savefigs()
  • show: Display the figure [default: True]
  • close: Close the figure at the end [default: False]
taylor(datasets, ref, labels=False, colors=None, units=None, normalize=True, **kwargs)[source]

Plot a Taylor diagram after computing statistics

Params:
  • datasets: One or several arrays that must be evaluated against the reference. Best is to provide cdms2 variables with an appropriate long_name attribute to set labels automatically.
  • ref: Reference array of the same shape as all datasets arrays.
  • labels,optional: Label of the points. Obviously, if there are several points, there must have several labels. If None, it tries to get it from the long_name attribute. If False, it doesn’t display it.
  • reflabel,optional: Name of the reference label. It defaults to the long_name attribute or to "Reference".
  • normalize,optional: Normalize standard deviation and RMSE
  • stdref, optional: Standard deviation of the reference used either when normalizing statistics or to plot the reference arc and point. All statistics can have a different reference standard deviation; in this case, statistics are normalized (normalize is set to True).
  • addref,optional: Add the reference arc and point to the plot.
  • normalize, optional: Force the normalization of statistics (standard deviations).
  • negative,optional: Force plot of negative correlations.
  • legend, optional: Add the legend.
  • size,optional: Size(s) of the markers in points.
  • colors,optional: Color of the points. It can be a list to set a different color for each pair.
  • cmap, optional: Colormap use when colors is a numeric array.
  • label_colors,optional: Color of the labels. If "same", color is taken from colors.
  • label_<keyword>,optional: <keyword> is passed to text() for plotting the labels.
  • symbols,optional: Symbols for the points (default to "o").
  • point_<keyword>,optional: <keyword> is passed to plot() (scatter() if scatter is True) or for plotting the points.
  • reflabel,optional: Label of the reference.
  • refcolor,optional: Color of the reference.
  • title,optional: A string for the general title.
  • scatter, optional: Use matplotlib.pyplot.scatter() to improve plot efficiency when the number of points is huge. Labels are not plotted in this mode.
  • savefig,optional: Save figure to savefig.
  • savefig_<keyword>,optional: <keyword> is used for saving figure.
  • savefigs,optional: Save figure to savefig using savefigs().
  • savefigs_<keyword>,optional: <keyword> is used for saving figure using savefigs().
Example:

Basic usage:

>>> taylor(var_model, var_obs, title='Single point', reflabel='Observations')

Two variables with the same reference:

>>> taylor([var_model1,var_model2], var_ref)

Two variables without the same reference (like temprature and salinity):

>>> taylor([sst,sss], [sstref,sssref], labels=True)

A huge model ensemble of SST with colors varying with averaged SSS:

>>> taylor([sstm for sstm in sstens], sstsat, colors=cdutil.averager(sss, 'xy'))
Tutorial:

Diagramme de Taylor”.

traj(lons, lats, res=None, dots=True, color=True, m=None, zoom=0.9, cmap=None, colorbar=True, **kwargs)[source]
vtaylor(data, ref=None, ref_color='red', color=None, label=None, title=None, xoffset=5, yoffset=-2, show=False, stdmax=None, savefig=None, **kwargs)[source]

Plot a Taylor diagram using vcs module from CDAT

  • data: A single or several points where a point is a pair of (std, corr).
  • ref: Reference value (standard deviation of observations).
  • color: Color of the points. It can be a list to set a different color for each pair.
  • label: Label of the points. Obviously, if there are several points, there must have several labels.
  • x|yoffset: Offset in font size unit of label position.
  • title: A string or False.
  • savefig: Save figure to savefig.
  • savefig_<keyword>: keyword is used for saving figure.
  • Other keywords are passed to plot().

Example:

>>> taylor([21.,.83], ref=30., title='Single point')
>>> taylor(([[[21.,.83], [33., .7]], ref=28., color=['blue', 242], label=['Point 1', 'Point2'])

Warning

This function uses the vcs module for plotting. Therefore, yan can’t alter the plot with matplotlib functions.

wedge(direction, width=18, fig=None, axes=None, figsize=(4, 4), shadow=False, shadow_alpha=0.5, circle=False, strength=None, strength_cmap=None, from_north=False, center=True, center_radius=0.04, scale=1.0, **kwargs)[source]

Plot a wedge

  • direction: Direction of the wedge in degrees from north
  • width: Base width of the wedge in degrees [default: 20]
  • shadow: Add a shadow [default: False]
  • shadow_alpha: Alpha transparency of the shadow [default: .5]
  • circle: Add a circle arround the wedge [default: True]
  • shadow_<keyword>: <keyword> is passed to matplotlib.patches.Shadow class.
  • circle_<keyword>: <keyword> is passed to matplotlib.patches.Circle class.
xdate(rotation=45.0, **kwargs)[source]

Consider x axis as dates

  • tz: Time zone.
  • auto: Auto Scaling [default: True]
  • rotation: Rotation angle of tick labels. If None, automatic [default: None]
  • fmt: Date format.
  • locator: Major locator. Can be within [‘year’,’month’,’Weekday’,’day’,’hour’,’minute’,’second’] or be like matplotlib.dates.MonthLocator().
  • minor_locator: Minor locator.
  • nominor: Do not try to add minor ticks [default: False]
  • nmax_ticks: Maximal number of ticks
  • locator_<keyword>: <keyword> is passed to locator if locator is a string. If locator = ‘month’, locator = MonthLocator(locator_<keyword>=<value>).
  • minor_locator_<keyword>: Same with minor_locator.
xhide(choice=True, **kwargs)[source]

Hide or not an axis

  • choice: What to do [default: True]
xi2a(inch, data=None)[source]

Convert from inch to X axis coordinates

xi2f(inch)[source]

Convert from inch to relative width of figure

xrotate(angle, *args, **kwargs)[source]

Rotate xticklabels

See: rotate_tick_labels()

xscale(*args, **kwargs)[source]

Scale xlim using factor and auto_scale

  • factor: Relative factor with 1. meaning no change
  • keep_min/keep_max: Kee min/max during scaling [default: False]

Return: New xlim()

ydate(rotation=0.0, **kwargs)[source]

Consider y axis as dates

  • tz: Time zone.
  • auto: Auto Scaling [default: True]
  • rotation: Rotation angle of tick labels. If None, automatic [default: None]
  • fmt: Date format.
  • locator: Major locator. Can be within [‘year’,’month’,’Weekday’,’day’,’hour’,’minute’,’second’] or be like matplotlib.dates.MonthLocator().
  • minor_locator: Minor locator.
  • nominor: Do not try to add minor ticks [default: False]
  • nmax_ticks: Maximal number of ticks
  • locator_<keyword>: <keyword> is passed to locator if locator is a string. If locator = ‘month’, locator = MonthLocator(locator_<keyword>=<value>).
  • minor_locator_<keyword>: Same with minor_locator.
yhide(choice=True, **kwargs)[source]

Hide or not an axis

  • choice: What to do [default: True]
yi2a(inch, data=None)[source]

Convert from inch to Y axis coordinates

yi2f(inch)[source]

Convert from inch to relative height of figure

yrotate(angle, *args, **kwargs)[source]

Rotate yticklabels

See: rotate_tick_labels()

yscale(*args, **kwargs)[source]

Scale ylim using factor and auto_scale

  • factor: Relative factor with 1. meaning no change
  • keep_min/keep_max: Kee min/max during scaling [default: False]

Return: New ylim()