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.

See the __main__ function for examples of use.

Module classes

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

Encapsulates a plotting environment, optimized for radiometry plots.

This class provides a wrapper around Matplotlib to provide a plotting environment specialised towards radiometry results. These functions were developed to provide well labelled plots by entering only one or two lines.

Provision is made for plots containing subplots (i.e. multiple plots on the same figure), linear scale and log scale plots, and cartesian and polar plots. Simple 3D line plots can also be made.

buildPlotCol(plotCol, n)

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.

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.
getPlot()

Returns a handle to the current plot

Args:
None
Returns:
A handle to the current plot.
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.
Raises:
No exception is raised.
logLog(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], label=[], legendAlpha=0.0, pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xIsDate=False, xTicks=None, xtickRotation=0, markers=[])

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
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 line style, list with M entries, use default if [] (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparancy for legend (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. default if all zeros. (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
powerLimits[float]: axis notation power limits [x-neg, x-pos, y-neg, y-pos] (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y label font size, default 12pt (optional)
xytickfsize (int): x, y tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xIsDate (bool): convert the x-values to dates
xTicks ({tick:label}): dict of ticks and associated labels
xtickRotation (float) ax tick rotation angle
markers ([string]) markers to be used in lines
Returns:
Nothing
Raises:
No exception is raised.
meshContour(plotnum, xvals, yvals, zvals, numLevels=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 at 0x05882990>, cbarshow=False, cbarorientation='vertical', cbarcustomticks=[], cbarfontsize=12, drawGrid=False, yInvert=False, xInvert=False, contourFill=True, contourLine=True, logScale=False, negativeSolid=False, zeroContourLine=False)

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 data in zvals must be on a grid where the xvals vector correspond to the number of rows in zvals and the yvals vector corresponds to the number of columns in zvals.

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.

Args:
plotnum (int): subplot number
xvals (np.array[N,] or [N,1]): vector of x values
yvals (np.array[M,] or [M,1]): vector of y values
zvals (np.array[N,M]): values on a (x,y) grid
numLevels (int): values of contour levels
ptitle (string): plot title (optional)
xlabel (string): x axis label
ylabel (string): y axis label
shading (string): ‘flat’ | ‘gouraud’ (optional)
plotCol ([strings]): plot line style, list with M entries, use default if []
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. default if all zeros.
maxNX (int): draw maxNX+1 tick labels on x axis
maxNY (int): draw maxNY+1 tick labels on y axis
xScientific (bool): use scientific notation on x-axis
yScientific (bool): use scientific notation on x-axis
powerLimits[float]: axis notation power limits [x-neg, x-pos, y-neg, y-pos]
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y label font size, default 12pt (optional)
xytickfsize (int): x, y tick font size, default 10pt (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
drawGrid (bool): draw the grid on the plot
invertY (bool): invert the y-axis
invertX (bool): invert the x-axis
contourFill (bool): fill contours with colour
contourLine (bool): draw a series of contour lines
logScale (bool): do Z values on log scale, recompute colourbar vals
negativeSolid (bool): draw negative contours in solid lines, dashed otherwise
zeroContourLine (bool): draw the contour at zero
Returns:
Nothing
Raises:
No exception is raised.
myPlot(plotcommand, plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], label=[], legendAlpha=0.0, 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=[])

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
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 line style, list with M entries, use default if []
label ([strings]): legend label for ordinate, list with M entries
legendAlpha (float): transparancy for legend
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. default if all zeros.
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
powerLimits[float]: axis notation power limits [x-neg, x-pos, y-neg, y-pos]
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y label font size, default 12pt (optional)
xytickfsize (int): x, y tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
drawGrid (bool): draw the grid on the plot
xScientific (bool): use scientific notation on x-axis
yScientific (bool): use scientific notation on x-axis
yInvert (bool): invert the y-axis
xInvert (bool): invert the x-axis
xIsDate (bool): convert the x-values to dates
xTicks ({tick:label}): dict of ticks and associated labels
xtickRotation (float) ax tick rotation angle
markers ([string]) markers to be used in lines
Returns:
Nothing
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.
plot(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], label=[], legendAlpha=0.0, 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=[])

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
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 line style, list with M entries, use default if [] (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparancy for legend (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. default if all zeros. (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
powerLimits[float]: axis notation power limits [x-neg, x-pos, y-neg, y-pos]
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y label font size, default 12pt (optional)
xytickfsize (int): x, y tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xScientific (bool): use scientific notation on x-axis
yScientific (bool): use scientific notation on x-axis
drawGrid (bool): draw the grid on the plot
yInvert (bool): invert the y-axis
xInvert (bool): invert the x-axis
xIsDate (bool): convert the x-values to dates
xTicks ({tick:label}): dict of ticks and associated labels
xtickRotation (float) ax tick rotation angle
markers ([string]) markers to be used in lines
Returns:
Nothing
Raises:
No exception is raised.
plot3d(plotnum, x, y, z, ptitle=None, xlabel=None, ylabel=None, zlabel=None, plotCol=, []label=None, legendAlpha=0.0, titlefsize=12, xylabelfsize=12, xInvert=False, yInvert=False, zInvert=False)

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 vertices, each column representing a different function 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
x (np.array[N,] or [N,M]): x coordinates of vertices
y (np.array[N,] or [N,M]): y coordinates of vertices
z (np.array[N,] or [N,M]): z coordinates of vertices
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 line style, list with M entries, use default if [] (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparancy for legend (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
yInvert (bool): invert the y-axis
zInvert (bool): invert the z-axis
Returns:
Nothing
Raises:
No exception is raised.
plotArray(plotnum, inarray, slicedim=0, subtitles=None, xlabel=None, maxNX=0, maxNY=0, titlefsize=8, xylabelfsize=8, xytickfsize=8)

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): subplot number
inarray (array): np.array
slicedim (int): slice along columns (0) or rows (1)
subtitles (list): a list of strings as subtitles for each subplot
xlabel (string): x axis label (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, y label font size, default 12pt (optional)
xytickfsize (int): x, y tick font size, default 10pt (optional)
Returns:
Nothing
Raises:
No exception is raised.
plotMarkers(plotnum)

Add markers to the subplot

Args:
plotnum (int): subplot number
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, rscale=None, rgrid=None, thetagrid=[30], direction='counterclockwise', zerooffset=0, titlefsize=12)

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 the current 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
theta (np.array[N,] or [N,1]): angular abscissa
r (np.array[N,] or [N,M]): radial ordinates - could be M columns
ptitle (string): plot title (optional)
plotCol ([strings]): plot line style, list with M entries, use default if [] (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 be highlighted (optional)
highlightCol (string): highlighted colour string (optional)
highlightWidth (int): highlighted line width(optional)
legendAlpha (float): transparancy for legend (optional)
rscale ([rmin, rmax]): plotting limits. default if all 0 (optional)
rgrid ([rinc, rmax]): radial grid default if all 0. if rinc=0 then rmax is number of ntervals. (optional)
thetagrids (float): theta grid interval [degrees] (optional)
direction (string)= ‘counterclockwise’ or ‘clockwise’ (optional)
zerooffset (float) = rotation offset where zero should be [rad] (optional)
titlefsize (int): title font size, default 12pt (optional)
Returns:
Nothing
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 at 0x05882990>)

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
theta (np.array[N,] or [N,1]): vector of angular values
radial (np.array[M,] or [M,1]): vector if radial values
zvals (np.array[N,M]): values on a (theta,radial) 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)
Returns:
Nothing
Raises:
No exception is raised.
polarMesh(plotnum, theta, radial, zvals, ptitle=None, shading='flat', radscale=None, titlefsize=12, meshCmap=<matplotlib.colors.LinearSegmentedColormap object at 0x05882990>, cbarshow=False, cbarorientation='vertical', cbarcustomticks=[], cbarfontsize=12, rgrid=[5], thetagrid=[30], drawGrid=False, thetagridfontsize=12, radialgridfontsize=12, direction='counterclockwise', zerooffset=0, logScale=False, plotCol=[], numLevels=10, contourLine=True, zeroContourLine=False)

Polar colour 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.

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 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
theta (np.array[N,] or [N,1]): vector of angular values [0..2pi]
radial (np.array[M,] or [M,1]): vector of radial values
zvals (np.array[N,M]): values on a (theta,radial) 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
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 line style, list with M entries, use default if []
numLevels (int): values of contour levels
contourLine (bool): draw a series of contour lines
zeroContourLine (bool): draw the contour at zero
Returns:
Nothing
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.

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=[], label=[], legendAlpha=0.0, pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xIsDate=False, xTicks=None, xtickRotation=0, markers=[])

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
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 line style, list with M entries, use default if [] (optional)
label ([strings]): legend label for ordinate, list with M entries (optional)
legendAlpha (float): transparancy for legend (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. default if all zeros. (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
powerLimits[float]: axis notation power limits [x-neg, x-pos, y-neg, y-pos] (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y label font size, default 12pt (optional)
xytickfsize (int): x, y tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xIsDate (bool): convert the x-values to dates
xTicks ({tick:label}): dict of ticks and associated labels
xtickRotation (float) ax tick rotation angle
markers ([string]) markers to be used in lines
Returns:
Nothing
Raises:
No exception is raised.
semilogY(plotnum, x, y, ptitle=None, xlabel=None, ylabel=None, plotCol=[], label=[], legendAlpha=0.0, pltaxis=None, maxNX=10, maxNY=10, linestyle=None, powerLimits=[-4, 2, -4, 2], titlefsize=12, xylabelfsize=12, xytickfsize=10, labelfsize=10, xIsDate=False, xTicks=None, xtickRotation=0, markers=[])

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
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 line style, list with M entries, use default if [] (optional)
label ([strings]): legend label for ordinate, list withM entries (optional)
legendAlpha (float): transparancy for legend (optional)
pltaxis ([xmin, xmax, ymin,ymax]): scale for x,y axes. default if all zeros. (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
powerLimits[float]: axis notation power limits [x-neg, x-pos, y-neg, y-pos] (optional)
titlefsize (int): title font size, default 12pt (optional)
xylabelfsize (int): x, y label font size, default 12pt (optional)
xytickfsize (int): x, y tick font size, default 10pt (optional)
labelfsize (int): label/legend font size, default 10pt (optional)
xIsDate (bool): convert the x-values to dates
xTicks ({tick:label}): dict of ticks and associated labels
xtickRotation (float) ax tick rotation angle
markers ([string]) markers to be used in lines
Returns:
Nothing
Raises:
No exception is raised.
showImage(plotnum, img, ptitle=None, cmap=<matplotlib.colors.LinearSegmentedColormap object at 0x05875CD0>, titlefsize=12, cbarshow=False, cbarorientation='vertical', cbarcustomticks=, []cbarfontsize=12)

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

Args:
plotnum (int): subplot number
img (np.ndarray): numpy 2d array
ptitle (string): plot title (optional)
cmap: matplotlib colormap, default gray (optional)
fsize (int): title font size, default 12pt (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
Returns:
Nothing
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 maker 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)

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 function names as pairs, and below invoke the pair elements cases are as follows: linear, log. sqrt. Note that the image is histogram equalised in all cases.

Module functions

pyradi.ryplot.savePlot(*args, **kwds)

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

Use as follows:

x=numpy.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.

Table Of Contents

Previous topic

File reading/writing utility

Next topic

Spherical Plotting utility

This Page