ClawPlotItem

For usage see Specifying the desired plots (usually in setplot.py) and Plotting examples.

Objects of this class are usually created by the new_plotitem method of a ClawPlotAxes object.

class ClawPlotItem

Attributes

The following attributes can be set by the user:

plot_type : str

Plot type, one of the following:

  • ‘1d’ : one dimensional line or set of points,
  • ‘1d_from_2d_data’ : 1d plot generated from 2d data, for example as a slice of the data or a scatter plot of data that should be radially symmetric,
  • ‘2d_contour’ : two dimensional contour plot,
  • ‘2d_pcolor’ : two dimensional pcolor plot,
outdir : str or None
Directory to find data to be plotted. If None, then data comes from the outdir attribute of the parent ClawPlotData item.
plot_var : int or function

If an integer, then this specifies which component of q to plot (with the Python convention that plot_var=0 corresponds to the first component).

If a function, then this function is applied to q on each grid to compute the variable var that is plotted. The signature is

  • var = plot_var(q, x, t) for 1d plot_type’s
  • var = plot_var(q, x, y, t) for 2d plot_type’s

where x [,y] is the array of cell centers and t is the time.

aftergrid : str or function or None

If a str, this string is executed with exec(aftergrid) after plotting data from each grid.

If a function, this function is called after plotting data from each grid. Signature:

  • aftergrid(gridno, frameno, plotitem)

This is useful for setting some aspect of the plot not handled by other means or to do something with the data from each grid.

show : bool
If False, plotting of this object is suppressed.

The other attributes required depend on the plot_type, as summarized below:

For all 1d plots, plot_type = ‘1d...’

plotstyle : str

Anything that is valid as a fmt group in the matplotlib plot command. For example:

  • ‘-‘ for a solid line, ‘- -‘ for a dashed line,
  • ‘o’ for circles, ‘x’ for x’s, ‘-o’ for circles and a line,
color : str
Any matplotlib color, for example red can be specified as ‘r’ or ‘red’ or ‘[1,0,0]’ or ‘#ff0000’.

For plot_type = ‘1d’

No extra attributes.

For plot_type = ‘1d_from_2d_data’

map_2d_to_1d : function

For plot_type = ‘2d_contour’

contour_levels : numpy array or None
If a numpy array, the contour levels. If None, then the next three attributes are used to set the levels.
contour_nlevels : int
Number of contour levels
contour_min : float
Minimum contour level
contour_max : float
Maximum contour level
contour_kwargs : dictionary
Other keyword arguments for the contour command.

For plot_type = ‘2d_pcolor’

pcolor_cmap : matplotlib colormap
pcolor_cmin : float
pcolor_cmax : float
pcolor_colorbar : bool
If True, a colorbar is added to the plot.

Methods

getframe(frameno)
Returns an object of class ClawSolution containing the solution being plotted by this object for frame number frameno.
gethandle()
Returns the handle for this item.