Plotting utility

Overview

This module provides functions for plotting cartesian and polar plots. This class provides a basic plotting capability, with a minimum number of lines. These are all wrapper functions, based on existing functions in other Python classes. Provision is made for combinations of linear and log scales, as well as polar plots for two-dimensional graphs. The Plotter class can save files to disk in a number of formats.

For more examples of use see: https://github.com/NelisW/ComputationalRadiometry

See the __main__ function for examples of use.

This package was partly developed to provide additional material in support of students and readers of the book Electro-Optical System Analysis and Design: A Radiometry Perspective, Cornelius J. Willers, ISBN 9780819495693, SPIE Monograph Volume PM236, SPIE Press, 2013. http://spie.org/x648.html?product_id=2021423&origin_id=x646

Module classes

class pyradi.ryplot.Plotter(fignumber=0, subpltnrow=1, subpltncol=1, figuretitle=None, figsize=(9, 9), titlefontsize=14, useplotly=False, doWarning=True)

Encapsulates a plotting environment, optimized for compact code.

This class provides a wrapper around Matplotlib to provide a plotting environment specialised towards typical pyradi visualisation. These functions were developed to provide sophisticated plots by entering the various plot options on a few lines, instead of typing many commands.

Provision is made for plots containing subplots (i.e., multiple plots on the same figure), linear scale and log scale plots, images, and cartesian, 3-D and polar plots.

buildPlotCol(plotCol=None, n=None)

Set a sequence of default colour styles of appropriate length.

The constructor provides a sequence with length 14 pre-defined plot styles. The user can define a new sequence if required. This function modulus-folds either sequence, in case longer sequences are required.

Colours can be one of the basic colours: [‘b’, ‘g’, ‘r’, ‘c’, ‘m’, ‘y’, ‘k’] or it can be a gray shade float value between 0 and 1, such as ‘0.75’, or it can be in hex format ‘#eeefff’ or it can be one of the legal html colours. See http://html-color-codes.info/ and http://www.computerhope.com/htmcolor.htm. http://latexcolor.com/

Args:
plotCol ([strings]): User-supplied list
of plotting styles(can be empty []).
n (int): Length of required sequence.
Returns:
A list with sequence of plot styles, of required length.
Raises:
No exception is raised.
emptyPlot(plotnum, projection='rectilinear')

Returns a handler to an empty plot.

This function does not do any plotting, the use must add plots using the standard MatPlotLib means.

Args:
plotnum (int): subplot number, 1-based index
rectilinear (str): type of axes projection, from [‘aitoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear.].
Returns:
the axis object for the plot
Raises:
No exception is raised.
getPlot()

Returns a handle to the current figure

Args:
None
Returns:
A handle to the current figure.
Raises:
No exception is raised.
getSubPlot(subplotNum=1)

Returns a handle to the subplot, as requested per subplot number. Subplot numbers range from 1 upwards.

Args:
subplotNumer (int) : number of the subplot
Returns:
A handle to the requested subplot or None if not found.
Raises:
No exception is raised.
getXLim(subplotNum=1)

Returns the x limits of the current subplot. Subplot numbers range from 1 upwards.

Args:
subplotNumer (int) : number of the subplot
Returns:
An array with the two limits
Raises:
No exception is raised.
getYLim(subplotNum=1)

Returns the y limits of the current subplot. Subplot numbers range from 1 upwards.

Args:
subplotNumer (int) : number of the subplot
Returns:
An array with the two limits
Raises:
No exception is raised.
horizontalLineCoords(subplotNum=1, y=0)

Returns two arrays for horizontal line at y in the specific subplot.

The line is drawn at specified y, with current x limits in subplot. Subplot numbers range from 1 upwards.

Use as follows to draw a horizontal line in plot:

p.plot(1,*p.horizontalLineCoords(subplotNum=1,x=freq),plotCol=[‘k’])

Args:
subplotNumer (int) : number of the subplot
y (double): horizontal value used for line
Returns:
A tuple with two arrays for line (x-coords,y-coords)
Raises:
No exception is raised.
labelSubplot(spax, ptitle=None, xlabel=None, ylabel=None, zlabel=None, titlefsize=10, labelfsize=10)

Set the sub-figure title and axes labels (cartesian plots only).

Args:
spax (handle): subplot axis handle where labels must be drawn
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
zlabel (string): z axis label (optional)
titlefsize (float): title fontsize (optional)
labelfsize (float): x,y,z label fontsize (optional)
Returns:
None.
Raises:
No exception is raised.
logLog(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], linewidths=None, label=[], legendAlpha=0.0, legendLoc='best', pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xScientific=False, yScientific=False, yInvert=False, xInvert=False, drawGrid=True, xIsDate=False, xTicks=None, xtickRotation=0, markers=[], markevery=None, zorders=None, clip_on=True, axesequal=False, xAxisFmt=None, yAxisFmt=None, PLcolor=None, PLwidth=None, PLdash=None, PLyAxisSide=None, PLyAxisOverlaying=None, PLmultipleYAxis=False, PLmultiAxisTitle=None)

Plot data on logarithmic scales for abscissa and ordinates.

Given an existing figure, this function plots in a specified subplot position. The function arguments are described below in some detail. Note that the y-values or ordinates can be more than one column, each column representing a different line in the plot. This is convenient if large arrays of data must be plotted. If more than one column is present, the label argument can contain the legend labels for each of the columns/lines. The pltaxis argument defines the min/max scale values for the x and y axes.

Args:
plotnum (int): subplot number, 1-based index
x (np.array[N,] or [N,1]): abscissa
y (np.array[N,] or [N,M]): ordinates - could be M columns
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if [] (optional)
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparency for legend box (optional)
legendLoc (string): location for legend box (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None. (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None. (optional)
maxNX (int): draw maxNX+1 tick labels on x axis (optional)
maxNY (int): draw maxNY+1 tick labels on y axis (optional)
linestyle (string): linestyle for this plot (optional)
powerLimits[float]: scientific tick label power limits [x-low, x-high, y-low, y-high] (optional) (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
drawGrid (bool): draw the grid on the plot (optional)
yInvert (bool): invert the y-axis (optional)
xInvert (bool): invert the x-axis (optional)
xIsDate (bool): convert the datetime x-values to dates (optional)
xTicks ({tick:label}): dict of x-axis tick locations and associated labels (optional)
xtickRotation (float) x-axis tick label rotation angle (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
zorders ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
axesequal (bool) force scaling on x and y axes to be equal (optional)
xAxisFmt (string) x-axis format string, e.g., ‘%.2f’, default None (optional)
yAxisFmt (string) y-axis format string, e.g., ‘%.2e’,, default None (optional)
PLcolor (string): graph color scheme. Format ‘rgb(r,g,b)’
PLwidth
PLdash (string): Line stlye
PLyAxisSide (string): Sets the location of the y-axis (left/right)
PLyAxisOverlaying (string): Sets the overlaying
PLmultipleYAxis (bool): Indicates presence of multiple axis
PLmultiAxisTitle (string): Sets the title of the multiple axis
Returns:
the axis object for the plot
Raises:
No exception is raised.
mesh3D(plotnum, xvals, yvals, zvals, ptitle=None, xlabel=None, ylabel=None, zlabel=None, rstride=1, cstride=1, linewidth=0, plotCol=None, edgeCol=None, pltaxis=None, maxNX=0, maxNY=0, maxNZ=0, xScientific=False, yScientific=False, zScientific=False, powerLimits=[-4, 2, -4, 2, -2, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, wireframe=False, surface=True, cmap=<matplotlib.colors.LinearSegmentedColormap object>, cbarshow=False, cbarorientation='vertical', cbarcustomticks=[], cbarfontsize=12, drawGrid=True, xInvert=False, yInvert=False, zInvert=False, logScale=False, alpha=1, alphawire=1, azim=45, elev=30, distance=10, zorders=None, clip_on=True, PLcolor=None, PLcolorScale=None, PLtickmode=None, PLnticks=None, PLtick0=None, PLdtick=None, PLtickvals=None, PLticktext=None, PLintensity=None)

XY colour mesh plot for (xvals, yvals, zvals) input sets.

Given an existing figure, this function plots in a specified subplot position. Only one mesh is drawn at a time. Future meshes in the same subplot will cover any previous meshes.

The mesh grid is defined in (x,y), while the height of the mesh is the z value.

The data set must have three two dimensional arrays, each for x, y, and z. The data in x, y, and z arrays must have matching data points. The x and y arrays each define the grid in terms of x and y values, i.e., the x array contains the x values for the data set, while the y array contains the y values. The z array contains the z values for the corresponding x and y values in the mesh.

Use wireframe=True to obtain a wireframe plot.

Use surface=True to obtain a surface plot with fill colours.

Z-values can be plotted on a log scale, in which case the colourbar is adjusted to show true values, but on the nonlinear scale.

The xvals and yvals vectors may have non-constant grid-intervals, i.e., they do not have to be on regular intervals, but z array must correspond to the (x,y) grid.

Args:
plotnum (int): subplot number, 1-based index
xvals (np.array[N,M]): array of x values, corresponding to (x,y) grid
yvals (np.array[N,M]): array of y values, corresponding to (x,y) grid
zvals (np.array[N,M]): array of z values, corresponding to (x,y) grid
ptitle (string): plot title (optional)
xlabel (string): x axis label (optional)
ylabel (string): y axis label (optional)
zlabel (string): z axis label (optional)
rstride (int): mesh line row (y axis) stride, every rstride value along y axis (optional)
cstride (int): mesh line column (x axis) stride, every cstride value along x axis (optional)
linewidth (float): mesh line width in points (optional)
plotCol ([strings]): fill colour, list with M=1 entries, use default if None (optional)
edgeCol ([strings]): mesh line colour , list with M=1 entries, use default if None (optional)
pltaxis ([xmin, xmax, ymin, ymax]): scale for x,y axes. z scale is not settable. Let Matplotlib decide if None (optional)
maxNX (int): draw maxNX+1 tick labels on x axis (optional)
maxNY (int): draw maxNY+1 tick labels on y axis (optional)
maxNZ (int): draw maxNY+1 tick labels on z axis (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
zScientific (bool): use scientific notation on z-axis (optional)
powerLimits[float]: scientific tick label power limits [x-neg, x-pos, y-neg, y-pos, z-neg, z-pos] (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis, z-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis, z-axis tick font size, default 10pt (optional)
wireframe (bool): If True, do a wireframe plot, (optional)
surface (bool): If True, do a surface plot, (optional)
cmap (cm): color map for the mesh (optional)
cbarshow (bool): if true, the show a color bar (optional)
cbarorientation (string): ‘vertical’ (right) or ‘horizontal’ (below) (optional)
cbarcustomticks zip([z values/float],[tick labels/string]): define custom colourbar ticks locations for given z values(optional)
cbarfontsize (int): font size for color bar (optional)
drawGrid (bool): draw the grid on the plot (optional)
xInvert (bool): invert the x-axis. Flip the x-axis left-right (optional)
yInvert (bool): invert the y-axis. Flip the y-axis left-right (optional)
zInvert (bool): invert the z-axis. Flip the z-axis up-down (optional)
logScale (bool): do Z values on log scale, recompute colourbar vals (optional)
alpha (float): surface transparency (optional)
alphawire (float): mesh transparency (optional)
azim (float): graph view azimuth angle [degrees] (optional)
elev (float): graph view evelation angle [degrees] (optional)
distance (float): distance between viewer and plot (optional)
zorder ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
PLcolor (string): Graph colors e.g ‘FFFFFF’
PLcolorScale ([int,string]): Color scale for mesh graphs e.g [0, ‘rgb(0, 0, 0)’]
PLtickmode (string): Plot mode
PLnticks (int): number of ticks
PLtick0 (int): First tick value
PLdtick (int):
PLtickvals [int]: Plot intervals
PLticktext [string]: Plot text
PLintensity
Returns:
the axis object for the plot
Raises:
No exception is raised.
meshContour(plotnum, xvals, yvals, zvals, levels=10, ptitle=None, xlabel=None, ylabel=None, shading='flat', plotCol=[], pltaxis=None, maxNX=0, maxNY=0, xScientific=False, yScientific=False, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, meshCmap=<matplotlib.colors.LinearSegmentedColormap object>, cbarshow=False, cbarorientation='vertical', cbarcustomticks=[], cbarfontsize=12, drawGrid=False, yInvert=False, xInvert=False, contourFill=True, contourLine=True, logScale=False, negativeSolid=False, zeroContourLine=None, contLabel=False, contFmt='%.2f', contCol='k', contFonSz=8, contLinWid=0.5, zorders=None, PLcolorscale='')

XY colour mesh countour plot for (xvals, yvals, zvals) input sets.

The data values must be given on a fixed mesh grid of three-dimensional $(x,y,z)$ array input sets. The mesh grid is defined in $(x,y)$, while the height of the mesh is the $z$ value.

Given an existing figure, this function plots in a specified subplot position. Only one contour plot is drawn at a time. Future contours in the same subplot will cover any previous contours.

The data set must have three two dimensional arrays, each for x, y, and z. The data in x, y, and z arrays must have matching data points. The x and y arrays each define the grid in terms of x and y values, i.e., the x array contains the x values for the data set, while the y array contains the y values. The z array contains the z values for the corresponding x and y values in the contour mesh.

Z-values can be plotted on a log scale, in which case the colourbar is adjusted to show true values, but on the nonlinear scale.

The current version only saves png files, since there appears to be a problem saving eps files.

The xvals and yvals vectors may have non-constant grid-intervals, i.e., they do not have to be on regular intervals.

Args:
plotnum (int): subplot number, 1-based index
xvals (np.array[N,M]): array of x values
yvals (np.array[N,M]): array of y values
zvals (np.array[N,M]): values on a (x,y) grid
levels (int or [float]): number of contour levels or a list of levels (optional)
ptitle (string): plot title (optional)
xlabel (string): x axis label (optional)
ylabel (string): y axis label (optional)
shading (string): not used currently (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if [] (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None. (optional)
maxNX (int): draw maxNX+1 tick labels on x axis (optional)
maxNY (int): draw maxNY+1 tick labels on y axis (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
powerLimits[float]: scientific tick label power limits [x-low, x-high, y-low, y-high] (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
meshCmap (cm): colour map for the mesh (optional)
cbarshow (bool): if true, the show a colour bar (optional)
cbarorientation (string): ‘vertical’ (right) or ‘horizontal’ (below) (optional)
cbarcustomticks zip([z values/float],[tick labels/string])` define custom colourbar ticks locations for given z values(optional)
cbarfontsize (int): font size for colour bar (optional)
drawGrid (bool): draw the grid on the plot (optional)
yInvert (bool): invert the y-axis. Flip the y-axis up-down (optional)
xInvert (bool): invert the x-axis. Flip the x-axis left-right (optional)
contourFill (bool): fill contours with colour (optional)
contourLine (bool): draw a series of contour lines (optional)
logScale (bool): do Z values on log scale, recompute colourbar values (optional)
negativeSolid (bool): draw negative contours in solid lines, dashed otherwise (optional)
zeroContourLine (double): draw a single contour at given value (optional)
contLabel (bool): label the contours with values (optional)
contFmt (string): contour label c-printf format (optional)
contCol (string): contour label colour, e.g., ‘k’ (optional)
contFonSz (float): contour label fontsize (optional)
contLinWid (float): contour line width in points (optional)
zorders ([int]) list of zorders for drawing sequence, highest is last (optional)
PLcolorscale (?) Plotly parameter ? (optional)
Returns:
the axis object for the plot
Raises:
No exception is raised.
myPlot(plotcommand, plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], linewidths=None, label=[], legendAlpha=0.0, legendLoc='best', pltaxis=None, maxNX=0, maxNY=0, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, drawGrid=True, xScientific=False, yScientific=False, yInvert=False, xInvert=False, xIsDate=False, xTicks=None, xtickRotation=0, markers=[], markevery=None, zorders=None, clip_on=True, axesequal=False, xAxisFmt=None, yAxisFmt=None, PLyStatic=[0])

Low level helper function to create a subplot and plot the data as required.

This function does the actual plotting, labelling etc. It uses the plotting function provided by its user functions.

lineStyles = { ‘’: ‘_draw_nothing’, ‘ ‘: ‘_draw_nothing’, ‘None’: ‘_draw_nothing’, ‘–’: ‘_draw_dashed’, ‘-.’: ‘_draw_dash_dot’, ‘-‘: ‘_draw_solid’, ‘:’: ‘_draw_dotted’}

Args:
plotcommand: name of a MatplotLib plotting function
plotnum (int): subplot number, 1-based index
ptitle (string): plot title
xlabel (string): x axis label
ylabel (string): y axis label
x (np.array[N,] or [N,1]): abscissa
y (np.array[N,] or [N,M]): ordinates - could be M columns
plotCol ([strings]): plot colour and line style, list with M entries, use default if []
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
label ([strings]): legend label for ordinate, list with M entries
legendAlpha (float): transparency for legend box
legendLoc (string): location for legend box (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None.
maxNX (int): draw maxNX+1 tick labels on x axis
maxNY (int): draw maxNY+1 tick labels on y axis
linestyle (string): linestyle for this plot (optional)
powerLimits[float]: scientific tick label power limits [x-low, x-high, y-low, y-high] (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
drawGrid (bool): draw the grid on the plot (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
yInvert (bool): invert the y-axis (optional)
xInvert (bool): invert the x-axis (optional)
xIsDate (bool): convert the datetime x-values to dates (optional)
xTicks ({tick:label}): dict of x-axis tick locations and associated labels (optional)
xtickRotation (float) x-axis tick label rotation angle (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
zorders ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
axesequal (bool) force scaling on x and y axes to be equal (optional)
xAxisFmt (string) x-axis format string, e.g., ‘%.2f’, default None (optional)
yAxisFmt (string) y-axis format string, e.g., ‘%.2e’,, default None (optional)
PLyStatic ([int]) the guy that added this did not document it properly
Returns:
the axis object for the plot
Raises:
No exception is raised.
nextPlotCol()

Returns the next entry in a sequence of default plot line colour styles in circular list. One day I want to do this with a generator….

Args:
None
Returns:
The next plot colour in the sequence.
Raises:
No exception is raised.
pie(plotnum, theta, radius, ptitle=None, angLabel='', radLabel='', thetaAxis=[0, 360.0], radiusAxis=[0, 1], plotCol=[], linewidths=None, label=[], legendAlpha=0.0, legendLoc='best', linestyle=None, titlefsize=12, numAngGrid=5, numRadGrid=10, labelfsize=10, drawGrid=True, markers=[], markevery=None, radangfsize=12, xytickfsize=10, zorders=None, clip_on=True, degreeformatter='%d$^\\circ$')

Plots data in pie section on a polar grid.

Args:
plotnum (int): subplot number, 1-based index
theta (np.array[N,] or [N,M]): angular data set in degrees - could be M columns
radius (np.array[N,] or [N,M]): radial data set - could be M columns
ptitle (string): plot title (optional)
angLabel (string): angular axis label (optional)
radLabel (string): radial axis label (optional)
thetaAxis ([minAngle, maxAnlge]): the angular extent to be displayed, degrees (optional)
radiusAxis ([minRad, maxRad]): the radial extent to be displayed, degrees (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if [] (optional)
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
label ([strings]): legend label for ordinate, list with M entries
legendAlpha (float): transparency for legend box
legendLoc (string): location for legend box (optional)
linestyle (string): linestyle for this plot (optional)
titlefsize (int): title font size, default 12pt (optional)
numAngGrid (int): number of grid or tick marks along angular extent
numRadGrid (int): number of grid or tick marks along angular extent
labelfsize (int): label/legend font size, default 10pt (optional)
drawGrid (bool): draw the grid on the plot (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
radangfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
zorders ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
degreeformatter (str) format string to defie the angular tick labels (optional)
Returns:
the axis object for the plot
Raises:
No exception is raised.
plot(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], linewidths=None, label=[], legendAlpha=0.0, legendLoc='best', pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xScientific=False, yScientific=False, yInvert=False, xInvert=False, drawGrid=True, xIsDate=False, xTicks=None, xtickRotation=0, markers=[], markevery=None, zorders=None, clip_on=True, axesequal=False, xAxisFmt=None, yAxisFmt=None, PLcolor=None, PLwidth=None, PLdash=None, PLyAxisSide=None, PLyAxisOverlaying=None, PLmultipleYAxis=False, PLmultiAxisTitle=None, PLxAxisSide=None, PLxAxisOverlaying=None, PLmultipleXAxis=False)

Cartesian plot on linear scales for abscissa and ordinates.

Given an existing figure, this function plots in a specified subplot position. The function arguments are described below in some detail. Note that the y-values or ordinates can be more than one column, each column representing a different line in the plot. This is convenient if large arrays of data must be plotted. If more than one column is present, the label argument can contain the legend labels for each of the columns/lines. The pltaxis argument defines the min/max scale values for the x and y axes.

Args:
plotnum (int): subplot number, 1-based index
x (np.array[N,] or [N,1]): abscissa
y (np.array[N,] or [N,M]): ordinates - could be M columns
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if [] (optional)
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparency for legend box (optional)
legendLoc (string): location for legend box (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None. (optional)
maxNX (int): draw maxNX+1 tick labels on x axis (optional)
maxNY (int): draw maxNY+1 tick labels on y axis (optional)
linestyle (string): linestyle for this plot (optional)
powerLimits[float]: scientific tick label power limits [x-low, x-high, y-low, y-high] (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
drawGrid (bool): draw the grid on the plot (optional)
yInvert (bool): invert the y-axis (optional)
xInvert (bool): invert the x-axis (optional)
xIsDate (bool): convert the datetime x-values to dates (optional)
xTicks ({tick:label}): dict of x-axis tick locations and associated labels (optional)
xtickRotation (float) x-axis tick label rotation angle (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
zorders ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
axesequal (bool) force scaling on x and y axes to be equal (optional)
xAxisFmt (string) x-axis format string, e.g., ‘%.2f’, default None (optional)
yAxisFmt (string) y-axis format string, e.g., ‘%.2e’,, default None (optional)
PLcolor (string): graph color scheme. Format ‘rgb(r,g,b)’
PLwidth
PLdash (string): Line stlye
PLyAxisSide (string): Sets the location of the y-axis (left/right)
PLyAxisOverlaying (string): Sets the overlaying
PLmultipleYAxis (bool): Indicates presence of multiple axis
PLmultiAxisTitle (string): Sets the title of the multiple axis
PLxAxisSide (string): Sets the location of the x-axis (top/bottom)
PLxAxisOverlaying (string): Sets the overlaying
PLmultipleXAxis (bool): Indicates presence of multiple axis
Returns:
the axis object for the plot
Raises:
No exception is raised.
plot3d(plotnum, x, y, z, ptitle=None, xlabel=None, ylabel=None, zlabel=None, plotCol=[], linewidths=None, pltaxis=None, label=None, legendAlpha=0.0, titlefsize=12, xylabelfsize=12, xInvert=False, yInvert=False, zInvert=False, scatter=False, markers=None, markevery=None, azim=45, elev=30, zorders=None, clip_on=True, edgeCol=None, linestyle='-')

3D plot on linear scales for x y z input sets.

Given an existing figure, this function plots in a specified subplot position. The function arguments are described below in some detail.

Note that multiple 3D data sets can be plotted simultaneously by adding additional columns to the input coordinates of the (x,y,z) arrays, each set of columns representing a different line in the plot. This is convenient if large arrays of data must be plotted. If more than one column is present, the label argument can contain the legend labels for each of the columns/lines.

Args:
plotnum (int): subplot number, 1-based index
x (np.array[N,] or [N,M]) x coordinates of each line.
y (np.array[N,] or [N,M]) y coordinates of each line.
z (np.array[N,] or [N,M]) z coordinates of each line.
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
zlabel (string): z axis label (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if None (optional)
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
pltaxis ([xmin, xmax, ymin, ymax, zmin, zmax]) scale for x,y,z axes. Let Matplotlib decide if None. (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparency for legend box (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y, z label font size, default 12pt (optional)
xInvert (bool): invert the x-axis (optional)
yInvert (bool): invert the y-axis (optional)
zInvert (bool): invert the z-axis (optional)
scatter (bool): draw only the points, no lines (optional)
markers ([string]): markers to be used for plotting data points (optional)
markevery (int | (startind, stride)): subsample when using markers (optional)
azim (float): graph view azimuth angle [degrees] (optional)
elev (float): graph view evelation angle [degrees] (optional)
zorder ([int]): list of zorder for drawing sequence, highest is last (optional)
clip_on (bool): clips objects to drawing axes (optional)
edgeCol ([int]): list of colour specs, value at [0] used for edge colour (optional).
linestyle (string): linestyle for this plot (optional)
Returns:
the axis object for the plot
Raises:
No exception is raised.
plotArray(plotnum, inarray, slicedim=0, labels=None, maxNX=0, maxNY=0, titlefsize=8, xylabelfsize=8, xytickfsize=8, selectCols=None, sepSpace=0.2, allPlotCol='r')

Creates a plot from an input array.

Given an input array with m x n dimensions, this function creates a subplot for vectors [1-n]. Vector 0 serves as the x-axis for each subplot. The slice dimension can be in columns (0) or rows (1).

Args:
plotnum (int): The subplot number, 1-based index, according to Matplotlib conventions. This value must always be given, even if only a single 1,1 subplot is used.
inarray (np.array): data series to be plotted. Data direction can be cols or rows. The abscissa (x axis) values must be the first col/row, with ordinates in following cols/rows.
slicedim (int): slice along columns (0) or rows (1) (optional).
labels (list): a list of strings as labels for each subplot. x=labels[0], y=labels[1:] (optional).
maxNX (int): draw maxNX+1 tick labels on x axis (optional).
maxNY (int): draw maxNY+1 tick labels on y axis (optional).
titlefsize (int): title font size, default 12pt (optional).
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional).
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional).
selectCols ([int]): select columns for plot. Col 0 corresponds to col 1 in input data (because col 0 is abscissa),plot all if not given (optional).
sepSpace (float): vertical spacing between sub-plots in inches (optional).
allPlotCol (str): make all plot lines this colour (optional).
Returns:
Nothing
Raises:
No exception is raised.
polar(plotnum, theta, r, ptitle=None, plotCol=None, label=[], labelLocation=[-0.1, 0.1], highlightNegative=True, highlightCol='#ffff00', highlightWidth=4, legendAlpha=0.0, linestyle=None, rscale=None, rgrid=[0, 5], thetagrid=[30], direction='counterclockwise', zerooffset=0, titlefsize=12, drawGrid=True, zorders=None, clip_on=True, markers=[], markevery=None)

Create a subplot and plot the data in polar coordinates (linear radial orginates only).

Given an existing figure, this function plots in a specified subplot position. The function arguments are described below in some detail. Note that the radial values or ordinates can be more than one column, each column representing a different line in the plot. This is convenient if large arrays of data must be plotted. If more than one column is present, the label argument can contain the legend labels for each of the columns/lines. The scale for the radial ordinates can be set with rscale. The number of radial grid circles can be set with rgrid - this provides a somewhat better control over the built-in radial grid in matplotlib. thetagrids defines the angular grid interval. The angular rotation direction can be set to be clockwise or counterclockwise. Likewise, the rotation offset where the plot zero angle must be, is set with zerooffset.

For some obscure reason Matplitlib version 1.13 does not plot negative values on the polar plot. We therefore force the plot by making the values positive and then highlight it as negative.

Args:
plotnum (int): subplot number, 1-based index
theta (np.array[N,] or [N,1]): angular abscissa in radians
r (np.array[N,] or [N,M]): radial ordinates - could be M columns
ptitle (string): plot title (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if None (optional)
label ([strings]): legend label, list with M entries (optional)
labelLocation ([x,y]): where the legend should located (optional)
highlightNegative (bool): indicate if negative data must be highlighted (optional)
highlightCol (string): negative highlight colour string (optional)
highlightWidth (int): negative highlight line width(optional)
legendAlpha (float): transparency for legend box (optional)
linestyle ([str]): line style to be used in plot
rscale ([rmin, rmax]): radial plotting limits. use default setting if None. If rmin is negative the zero is a circle and rmin is at the centre of the graph (optional)
rgrid ([rinc, numinc]): radial grid, use default is [0,5]. If rgrid is None don’t show. If rinc=0 then numinc is number of intervals. If rinc is not zero then rinc is the increment and numinc is ignored (optional)
thetagrids (float): theta grid interval [degrees], if None don’t show (optional)
direction (string): direction in increasing angle, ‘counterclockwise’ or ‘clockwise’ (optional)
zerooffset (float): rotation offset where zero should be [rad]. Positive zero-offset rotation is counterclockwise from 3’o’clock (optional)
titlefsize (int): title font size, default 12pt (optional)
drawGrid (bool): draw a grid on the graph (optional)
zorder ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
Returns:
the axis object for the plot
Raises:
No exception is raised.
polar3d(plotnum, theta, radial, zvals, ptitle=None, xlabel=None, ylabel=None, zlabel=None, zscale=None, titlefsize=12, xylabelfsize=12, thetaStride=1, radialstride=1, meshCmap=<matplotlib.colors.LinearSegmentedColormap object>, linewidth=0.1, azim=45, elev=30, zorders=None, clip_on=True, facecolors=None, alpha=1, edgeCol=None)

3D polar surface/mesh plot for (r, theta, zvals) input sets.

Given an existing figure, this function plots in a specified subplot position.

Only one mesh is drawn at a time. Future meshes in the same subplot will cover any previous meshes.

The data in zvals must be on a grid where the theta vector correspond to the number of rows in zvals and the radial vector corresponds to the number of columns in zvals.

The r and p vectors may have non-constant grid-intervals, i.e., they do not have to be on regular intervals.

Args:
plotnum (int): subplot number, 1-based index
theta (np.array[N,M]): array of angular values [0..2pi] corresponding to (theta,rho) grid.
radial (np.array[N,M]): array of radial values corresponding to (theta,rho) grid.
zvals (np.array[N,M]): array of z values corresponding to (theta,rho) grid.
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
zlabel (string): z-axis label (optional)
zscale ([float]): z axis [min, max] in the plot.
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y, z label font size, default 12pt (optional)
thetaStride (int): theta stride in input data (optional)
radialstride (int): radial stride in input data (optional)
meshCmap (cm): color map for the mesh (optional)
linewidth (float): width of the mesh lines
azim (float): graph view azimuth angle [degrees] (optional)
elev (float): graph view evelation angle [degrees] (optional)
zorder ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
facecolors ((np.array[N,M]): array of z value facecolours, corresponding to (theta,rho) grid.
alpha (float): facecolour surface transparency (optional)
edgeCol ([int]): list of colour specs, value at [0] used for edge colour (optional).
Returns:
the axis object for the plot
Raises:
No exception is raised.
polarMesh(plotnum, theta, radial, zvals, ptitle=None, shading='flat', radscale=None, titlefsize=12, meshCmap=<matplotlib.colors.LinearSegmentedColormap object>, cbarshow=False, cbarorientation='vertical', cbarcustomticks=[], cbarfontsize=12, rgrid=[0, 5], thetagrid=[30], drawGrid=False, thetagridfontsize=12, radialgridfontsize=12, direction='counterclockwise', zerooffset=0, logScale=False, plotCol=[], levels=10, contourFill=True, contourLine=True, zeroContourLine=None, negativeSolid=False, contLabel=False, contFmt='%.2f', contCol='k', contFonSz=8, contLinWid=0.5, zorders=None, clip_on=True)

Polar colour contour and filled contour plot for (theta, r, zvals) input sets.

The data values must be given on a fixed mesh grid of three-dimensional (theta,rho,z) array input sets (theta is angle, and rho is radial distance). The mesh grid is defined in (theta,rho), while the height of the mesh is the z value. The (theta,rho) arrays may have non-constant grid-intervals, i.e., they do not have to be on regular intervals.

Given an existing figure, this function plots in a specified subplot position. Only one contour plot is drawn at a time. Future contours in the same subplot will cover any previous contours.

The data set must have three two dimensional arrays, each for theta, rho, and z. The data in theta, rho, and z arrays must have matching data points. The theta and rho arrays each define the grid in terms of theta and rho values, i.e., the theta array contains the angular values for the data set, while the rho array contains the radial values. The z array contains the z values for the corresponding theta and rho values in the contour mesh.

Z-values can be plotted on a log scale, in which case the colourbar is adjusted to show true values, but on the nonlinear scale.

The current version only saves png files, since there appears to be a problem saving eps files.

Args:
plotnum (int): subplot number, 1-based index
theta (np.array[N,M]) array of angular values [0..2pi] corresponding to (theta,rho) grid.
radial (np.array[N,M]) array of radial values corresponding to (theta,rho) grid.
zvals (np.array[N,M]) array of z values corresponding to (theta,rho) grid.
ptitle (string): plot title (optional)
shading (string): ‘flat’ | ‘gouraud’ (optional)
radscale ([float]): inner and outer radial scale max in the plot.
titlefsize (int): title font size, default 12pt (optional)
meshCmap (cm): color map for the mesh (optional)
cbarshow (bool): if true, the show a color bar
cbarorientation (string): ‘vertical’ (right) or ‘horizontal’ (below)
cbarcustomticks zip([tick locations/float],[tick labels/string]): locations in image grey levels
cbarfontsize (int): font size for color bar
rgrid ([float]): radial grid - None, [number], [inc,max]
thetagrid ([float]): angular grid - None, [inc]
drawGrid (bool): draw the grid on the plot (optional)
thetagridfontsize (float): font size for the angular grid
radialgridfontsize (float): font size for the radial grid
direction (string)= ‘counterclockwise’ or ‘clockwise’ (optional)
zerooffset (float) = rotation offset where zero should be [rad] (optional)
logScale (bool): do Z values on log scale, recompute colourbar vals
plotCol ([strings]): plot colour and line style, list with M entries, use default if []
levels (int or [float]): number of contour levels or a list of levels (optional)
contourFill (bool): fill contours with colour (optional)
contourLine (bool): draw a series of contour lines
zeroContourLine (double): draw a contour at the stated value (optional)
negativeSolid (bool): draw negative contours in solid lines, dashed otherwise (optional)
contLabel (bool): label the contours with values (optional)
contFmt (string): contour label c-printf format (optional)
contCol (string): contour label colour, e.g., ‘k’ (optional)
contFonSz (float): contour label fontsize (optional)
contLinWid (float): contour line width in points (optional)
zorder ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
Returns:
the axis object for the plot
Raises:
No exception is raised.
resetPlotCol()

Resets the plot colours to start at the beginning of the cycle.

Args:
None
Returns:
None.
Raises:
No exception is raised.
saveFig(filename='mpl.png', dpi=300, bbox_inches='tight', pad_inches=0.1, useTrueType=True)

Save the plot to a disk file, using filename, dpi specification and bounding box limits.

One of matplotlib’s design choices is a bounding box strategy which may result in a bounding box that is smaller than the size of all the objects on the page. It took a while to figure this out, but the current default values for bbox_inches and pad_inches seem to create meaningful bounding boxes. These are however larger than the true bounding box. You still need a tool such as epstools or Adobe Acrobat to trim eps files to the true bounding box.

The type of file written is picked up in the filename. Most backends support png, pdf, ps, eps and svg.

Args:
filename (string): output filename to write plot, file ext
dpi (int): the resolution of the graph in dots per inch
bbox_inches: see matplotlib docs for more detail.
pad_inches: see matplotlib docs for more detail.
useTrueType: if True, truetype fonts are used in eps/pdf files, otherwise Type3
Returns:
Nothing. Saves a file to disk.
Raises:
No exception is raised.
semilogX(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], linewidths=None, label=[], legendAlpha=0.0, legendLoc='best', pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xScientific=False, yScientific=False, yInvert=False, xInvert=False, drawGrid=True, xIsDate=False, xTicks=None, xtickRotation=0, markers=[], markevery=None, zorders=None, clip_on=True, axesequal=False, xAxisFmt=None, yAxisFmt=None, PLcolor=None, PLwidth=None, PLdash=None, PLyAxisSide=None, PLyAxisOverlaying=None, PLmultipleYAxis=False, PLmultiAxisTitle=None)

Plot data on logarithmic scales for abscissa and linear scale for ordinates.

Given an existing figure, this function plots in a specified subplot position. The function arguments are described below in some detail. Note that the y-values or ordinates can be more than one column, each column representing a different line in the plot. This is convenient if large arrays of data must be plotted. If more than one column is present, the label argument can contain the legend labels for each of the columns/lines. The pltaxis argument defines the min/max scale values for the x and y axes.

Args:
plotnum (int): subplot number, 1-based index
x (np.array[N,] or [N,1]): abscissa
y (np.array[N,] or [N,M]): ordinates - could be M columns
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if [] (optional)
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparency for legend box (optional)
legendLoc (string): location for legend box (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None. (optional)
maxNX (int): draw maxNX+1 tick labels on x axis (optional)
maxNY (int): draw maxNY+1 tick labels on y axis (optional)
linestyle (string): linestyle for this plot (optional)
powerLimits[float]: scientific tick label notation power limits [x-low, x-high, y-low, y-high] (optional) (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
drawGrid (bool): draw the grid on the plot (optional)
yInvert (bool): invert the y-axis (optional)
xInvert (bool): invert the x-axis (optional)
xIsDate (bool): convert the datetime x-values to dates (optional)
xTicks ({tick:label}): dict of x-axis tick locations and associated labels (optional)
xtickRotation (float) x-axis tick label rotation angle (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
zorders ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
axesequal (bool) force scaling on x and y axes to be equal (optional)
xAxisFmt (string) x-axis format string, e.g., ‘%.2f’, default None (optional)
yAxisFmt (string) y-axis format string, e.g., ‘%.2e’,, default None (optional)
PLcolor (string): graph color scheme. Format ‘rgb(r,g,b)’
PLwidth
PLdash (string): Line stlye
PLyAxisSide (string): Sets the location of the y-axis (left/right)
PLyAxisOverlaying (string): Sets the overlaying
PLmultipleYAxis (bool): Indicates presence of multiple axis
PLmultiAxisTitle (string): Sets the title of the multiple axis
Returns:
the axis object for the plot
Raises:
No exception is raised.
semilogY(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], linewidths=None, label=[], legendAlpha=0.0, legendLoc='best', pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xScientific=False, yScientific=False, yInvert=False, xInvert=False, drawGrid=True, xIsDate=False, xTicks=None, xtickRotation=0, markers=[], markevery=None, zorders=None, clip_on=True, axesequal=False, xAxisFmt=None, yAxisFmt=None, PLcolor=None, PLwidth=None, PLdash=None, PLyAxisSide=None, PLyAxisOverlaying=None, PLmultipleYAxis=False, PLmultiAxisTitle=None)

Plot data on linear scales for abscissa and logarithmic scale for ordinates.

Given an existing figure, this function plots in a specified subplot position. The function arguments are described below in some detail. Note that the y-values or ordinates can be more than one column, each column representing a different line in the plot. This is convenient if large arrays of data must be plotted. If more than one column is present, the label argument can contain the legend labels for each of the columns/lines. The pltaxis argument defines the min/max scale values for the x and y axes.

Args:
plotnum (int): subplot number, 1-based index
x (np.array[N,] or [N,1]): abscissa
y (np.array[N,] or [N,M]): ordinates - could be M columns
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if [] (optional)
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
label ([strings]): legend label for ordinate, list withM entries (optional)
legendAlpha (float): transparency for legend box (optional)
legendLoc (string): location for legend box (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None. (optional)
maxNX (int): draw maxNX+1 tick labels on x axis (optional)
maxNY (int): draw maxNY+1 tick labels on y axis (optional)
linestyle (string): linestyle for this plot (optional)
powerLimits[float]: scientific tick label power limits [x-low, x-high, y-low, y-high] (optional) (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
drawGrid (bool): draw the grid on the plot (optional)
yInvert (bool): invert the y-axis (optional)
xInvert (bool): invert the x-axis (optional)
xIsDate (bool): convert the datetime x-values to dates (optional)
xTicks ({tick:label}): dict of x-axis tick locations and associated labels (optional)
xtickRotation (float) x-axis tick label rotation angle (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
zorders ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
axesequal (bool) force scaling on x and y axes to be equal (optional)
xAxisFmt (string) x-axis format string, e.g., ‘%.2f’, default None (optional)
yAxisFmt (string) y-axis format string, e.g., ‘%.2e’,, default None (optional)
PLcolor (string): graph color scheme. Format ‘rgb(r,g,b)’
PLwidth
PLdash (string): Line stlye
PLyAxisSide (string): Sets the location of the y-axis (left/right)
PLyAxisOverlaying (string): Sets the overlaying
PLmultipleYAxis (bool): Indicates presence of multiple axis
PLmultiAxisTitle (string): Sets the title of the multiple axis
Returns:
the axis object for the plot
Raises:
No exception is raised.
setup_pie_axes(fig, rect, thetaAxis, radiusAxis, radLabel='', angLabel='', numAngGrid=5, numRadGrid=10, drawGrid=True, degreeformatter='%d$^\\circ$')

Sets up the axes_grid for the pie plot, not using regulat Matplotlib axes.

http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html http://matplotlib.org/mpl_toolkits/axes_grid/api/axis_artist_api.html http://matplotlib.org/mpl_toolkits/axes_grid/users/axisartist.html http://matplotlib.org/examples/axes_grid/demo_floating_axes.html https://fossies.org/dox/matplotlib-1.5.3/classmpl__toolkits_1_1axisartist_1_1angle__helper_1_1FormatterDMS.html

Args:
fig (matplotlib figure): which figure to use
rect (matplotlib subaxis): which subplot to use
thetaAxis ([float]): [min,max] for angular scale
radiusAxis ([float]): [min,max] for radial scale
radLabel (str): radial label
angLabel (str): angular label
numAngGrid (int): number of ticks on angular grid
numRadGrid (int): number of ticks on radial grid
drawGrid (bool): must grid be drawn?
degreeformatter (str): format string for angular tick labels
Returns:
the axes and parasitic axes object for the plot
Raises:
No exception is raised.
showImage(plotnum, img, ptitle=None, xlabel=None, ylabel=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, titlefsize=12, cbarshow=False, cbarorientation='vertical', cbarcustomticks=[], cbarfontsize=12, labelfsize=10, xylabelfsize=12, interpolation=None)

Creates a subplot and show the image using the colormap provided.

Args:
plotnum (int): subplot number, 1-based index
img (np.ndarray): numpy 2d array containing the image
ptitle (string): plot title (optional)
xlabel (string): x axis label (optional)
ylabel (string): y axis label (optional)
cmap: matplotlib colormap, default gray (optional)
fsize (int): title font size, default 12pt (optional)
cbarshow (bool): if true, the show a colour bar (optional)
cbarorientation (string): ‘vertical’ (right) or ‘horizontal’ (below) (optional)
cbarcustomticks zip([tick locations/float],[tick labels/string]): locations in image grey levels (optional)
cbarfontsize (int): font size for colour bar (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
interpolation (str): ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’, ‘mitchell’, ‘sinc’, ‘lanczos’(optional, see pyplot.imshow)
Returns:
the axis object for the plot
Raises:
No exception is raised.
stackplot(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], linewidths=None, label=[], legendAlpha=0.0, legendLoc='best', pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xScientific=False, yScientific=False, yInvert=False, xInvert=False, drawGrid=True, xIsDate=False, xTicks=None, xtickRotation=0, markers=[], markevery=None, zorders=None, clip_on=True, axesequal=False, xAxisFmt=None, yAxisFmt=None, PLcolor=None, PLwidth=None, PLdash=None, PLyAxisSide=None, PLyAxisOverlaying=None, PLmultipleYAxis=False, PLmultiAxisTitle=None)

Plot stacked data on linear scales for abscissa and ordinates.

Given an existing figure, this function plots in a specified subplot position. The function arguments are described below in some detail. Note that the y-values or ordinates can be more than one column, each column representing a different line in the plot. If more than one column is present, the label argument can contain the legend labels for each of the columns/lines. The pltaxis argument defines the min/max scale values for the x and y axes.

Args:
plotnum (int): subplot number, 1-based index
x (np.array[N,] or [N,1]): abscissa
y (np.array[N,] or [N,M]): ordinates - could be M columns
ptitle (string): plot title (optional)
xlabel (string): x-axis label (optional)
ylabel (string): y-axis label (optional)
plotCol ([strings]): plot colour and line style, list with M entries, use default if [] (optional)
linewidths ([float]): plot line width in points, list with M entries, use default if None (optional)
label ([strings]): legend label for ordinate, list withM entries (optional)
legendAlpha (float): transparency for legend box (optional)
legendLoc (string): location for legend box (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. Let Matplotlib decide if None. (optional)
maxNX (int): draw maxNX+1 tick labels on x axis (optional)
maxNY (int): draw maxNY+1 tick labels on y axis (optional)
linestyle (string): linestyle for this plot (optional)
powerLimits[float]: scientific tick label power limits [x-low, x-high, y-low, y-high] (optional) (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x-axis, y-axis label font size, default 12pt (optional)
xytickfsize (int): x-axis, y-axis tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xScientific (bool): use scientific notation on x axis (optional)
yScientific (bool): use scientific notation on y axis (optional)
drawGrid (bool): draw the grid on the plot (optional)
yInvert (bool): invert the y-axis (optional)
xInvert (bool): invert the x-axis (optional)
xIsDate (bool): convert the datetime x-values to dates (optional)
xTicks ({tick:label}): dict of x-axis tick locations and associated labels (optional)
xtickRotation (float) x-axis tick label rotation angle (optional)
markers ([string]) markers to be used for plotting data points (optional)
markevery (int | (startind, stride)) subsample when using markers (optional)
zorders ([int]) list of zorder for drawing sequence, highest is last (optional)
clip_on (bool) clips objects to drawing axes (optional)
axesequal (bool) force scaling on x and y axes to be equal (optional)
xAxisFmt (string) x-axis format string, e.g., ‘%.2f’, default None (optional)
yAxisFmt (string) y-axis format string, e.g., ‘%.2e’,, default None (optional)
PLcolor (string): graph color scheme. Format ‘rgb(r,g,b)’
PLwidth
PLdash (string): Line stlye
PLyAxisSide (string): Sets the location of the y-axis (left/right)
PLyAxisOverlaying (string): Sets the overlaying
PLmultipleYAxis (bool): Indicates presence of multiple axis
PLmultiAxisTitle (string): Sets the title of the multiple axis
Returns:
the axis object for the plot
Raises:
No exception is raised.
verticalLineCoords(subplotNum=1, x=0)

Returns two arrays for vertical line at x in the specific subplot.

The line is drawn at specified x, with current y limits in subplot. Subplot numbers range from 1 upwards.

Use as follows to draw a vertical line in plot:

p.plot(1,*p.verticalLineCoords(subplotNum=1,x=freq),plotCol=[‘k’])

Args:
subplotNumer (int) : number of the subplot
x (double): horizontal value used for line
Returns:
A tuple with two arrays for line (x-coords,y-coords)
Raises:
No exception is raised.
class pyradi.ryplot.FilledMarker(markerfacecolor=None, markerfacecoloralt=None, markeredgecolor=None, marker=None, markersize=None, fillstyle=None)

Filled marker user-settable values.

This class encapsulates a few variables describing a Filled marker. Default values are provided that can be overridden in user plots.

Values relevant to filled makers are as follows:
marker = [‘o’, ‘v’, ‘^’, ‘<’, ‘>’, ‘8’, ‘s’, ‘p’, ‘*’, ‘h’, ‘H’, ‘D’, ‘d’]
fillstyle = [‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’]
class pyradi.ryplot.Markers(markerfacecolor=None, markerfacecoloralt=None, markeredgecolor=None, marker=None, markersize=None, fillstyle=None)

Collect marker location and types and mark subplot.

Build a list of markers at plot locations with the specified marker.

add(x, y, markerfacecolor=None, markerfacecoloralt=None, markeredgecolor=None, marker=None, markersize=None, fillstyle=None)

Add a marker to the list, overridding properties if necessary.

Specify location and any specific marker properties to be used. The location can be (xy,y) for cartesian plots or (theta,rad) for polars.

If no marker properties are specified, the current marker class properties will be used. If the current maker instance does not specify properties, the default marker properties will be used.

Args:
x (float): the x/theta location for the marker
y (float): the y/radial location for the marker
markerfacecolor (colour): main colour for marker (optional)
markerfacecoloralt (colour): alterive colour for marker (optional)
markeredgecolor (colour): edge colour for marker (optional)
marker (string): string to specify the marker (optional)
markersize (int)): size of the marker (optional)
fillstyle (string): string to define fill style (optional)
Returns:
Nothing. Creates the figure for subequent use.
Raises:
No exception is raised.
plot(ax)

Plot the current list of markers on the given axes.

All the markers currently stored in the class will be drawn.

Args:
ax (axes): an axes handle for the plot
Returns:
Nothing. Creates the figure for subequent use.
Raises:
No exception is raised.
class pyradi.ryplot.ProcessImage

This class provides a functions to assist in the optimal display of images.

compressEqualizeImage(image, selectCompressSet=2, numCbarlevels=20, cbarformat='.3f')

Compress an image (and then inversely expand the color bar values), prior to histogram equalisation to ensure that the two keep in step, we store the compression function names as pairs, and invoke the compression function as follows: linear, log. sqrt. Note that the image is histogram equalised in all cases.

Args:
image (np.ndarray): the image to be processed
selectCompressSet (int): compression selection [0,1,2] (optional)
numCbarlevels (int): number of labels in the colourbar (optional)
cbarformat (string): colourbar label format, e.g., ‘10.3f’, ‘.5e’ (optional)
Returns:
imgHEQ (np.ndarray): the equalised image array
customticksz (zip(float, string)): colourbar levels and associated levels
Raises:
No exception is raised.
reprojectImageIntoPolar(data, origin=None, framesFirst=True, cval=0.0)

Reprojects a 3D numpy array into a polar coordinate system, relative to some origin.

This function reprojects an image from cartesian to polar coordinates. The origin of the new coordinate system defaults to the center of the image, unless the user supplies a new origin.

The data format can be data.shape = (rows, cols, frames) or data.shape = (frames, rows, cols), the format of which is indicated by the framesFirst parameter.

The reprojectImageIntoPolar function maps radial to cartesian coords. The radial image is however presented in a cartesian grid, the corners have no meaning. The radial coordinates are mapped to the radius, not the corners. This means that in order to map corners, the frequency is scaled with sqrt(2), The corners are filled with the value specified in cval.

Args:
data (np.array): 3-D array to which transformation must be applied.
origin ( (x-orig, y-orig) ): data-coordinates of where origin should be placed
framesFirst (bool): True if data.shape is (frames, rows, cols), False if data.shape is (rows, cols, frames)
cval (float): the fill value to be used in coords outside the mapped range(optional)
Returns:
output (float np.array): transformed images/array data in the same sequence as input sequence.
r_i (np.array[N,]): radial values for returned image.
theta_i (np.array[M,]): angular values for returned image.
Raises:
No exception is raised.

original code by Joe Kington https://stackoverflow.com/questions/3798333/image-information-along-a-polar-coordinate-system

Module functions

pyradi.ryplot.savePlot(fignumber=0, subpltnrow=1, subpltncol=1, figuretitle=None, figsize=(9, 9), saveName=None)

Uses ‘with’ statement to create a plot and save to file on exit.

Use as follows:

x=np.linspace(-3,3,20)
with savePlot(1,saveName=['testwith.png','testwith.eps']) as p:
    p.plot(1,x,x*x)

where the savePlot parameters are exactly the same as Plotter, except that a new named parameter saveName is now present. If saveName is not None, the list of filenames is used to save files of the plot (any number of names/types)

Args:
fignumber (int): the plt figure number, must be supplied
subpltnrow (int): subplot number of rows
subpltncol (int): subplot number of columns
figuretitle (string): the overall heading for the figure
figsize ((w,h)): the figure size in inches
saveName str or [str]: string or list of save filenames
Returns:
The plotting object, used to populate the plot (see example)
Raises:
No exception is raised.
pyradi.ryplot.cubehelixcmap(start=0.5, rot=-1.5, gamma=1.0, hue=1.2, reverse=False, nlev=256.0)

A full implementation of Dave Green’s “cubehelix” for Matplotlib. Based on the FORTRAN 77 code provided in D.A. Green, 2011, BASI, 39, 289.

http://adsabs.harvard.edu/abs/2011arXiv1108.5083G http://www.astron-soc.in/bulletin/11June/289392011.pdf

User can adjust all parameters of the cubehelix algorithm. This enables much greater flexibility in choosing color maps, while always ensuring the color map scales in intensity from black to white. A few simple examples:

Default color map settings produce the standard “cubehelix”.

Create color map in only blues by setting rot=0 and start=0.

Create reverse (white to black) backwards through the rainbow once by setting rot=1 and reverse=True.

Args:
start : scalar, optional
Sets the starting position in the color space. 0=blue, 1=red,
2=green. Defaults to 0.5.
rot : scalar, optional
The number of rotations through the rainbow. Can be positive
or negative, indicating direction of rainbow. Negative values
correspond to Blue->Red direction. Defaults to -1.5
gamma : scalar, optional
The gamma correction for intensity. Defaults to 1.0
hue : scalar, optional
The hue intensity factor. Defaults to 1.2
reverse : boolean, optional
Set to True to reverse the color map. Will go from black to
white. Good for density plots where shade~density. Defaults to False
nevl : scalar, optional
Defines the number of discrete levels to render colors at.
Defaults to 256.
Returns:
matplotlib.colors.LinearSegmentedColormap object

Example: >>> import cubehelix >>> cx = cubehelix.cmap(start=0., rot=-0.5) >>> plot(x,cmap=cx)

Revisions 2014-04 (@jradavenport) Ported from IDL version

source https://github.com/jradavenport/cubehelix

Licence Copyright (c) 2014, James R. A. Davenport and contributors All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.