mpas_analysis.shared.plot.plot_vertical_section¶
-
mpas_analysis.shared.plot.
plot_vertical_section
(config, xArray, depthArray, fieldArray, colorMapSectionName, suffix='', colorbarLabel=None, title=None, xlabel=None, ylabel=None, figsize=(10, 4), dpi=None, titleFontSize=None, titleY=None, axisFontSize=None, xLim=None, yLim=None, lineWidth=2, lineStyle='solid', lineColor='black', backgroundColor='grey', secondXAxisData=None, secondXAxisLabel=None, thirdXAxisData=None, thirdXAxisLabel=None, numUpperTicks=None, upperXAxisTickLabelPrecision=None, invertYAxis=True, xArrayIsTime=False, movingAveragePoints=None, firstYearXTicks=None, yearStrideXTicks=None, maxXTicks=20, calendar='gregorian', plotAsContours=False, contourComparisonFieldArray=None, comparisonFieldName=None, originalFieldName=None, comparisonContourLineStyle=None, comparisonContourLineColor=None, labelContours=False, contourLabelPrecision=1)[source]¶ Plots a data set as a x distance (latitude, longitude, or spherical distance) vs depth map (vertical section).
Or, if xArrayIsTime is True, plots data set on a vertical Hovmoller plot (depth vs. time).
Typically, the fieldArray data are plotted using a heatmap, but if contourComparisonFieldArray is not None, then contours of both fieldArray and contourComparisonFieldArray are plotted instead.
- Parameters
config (instance of ConfigParser) – the configuration, containing a [plot] section with options that control plotting
xArray (float array) – x array (latitude, longitude, or spherical distance; or, time for a Hovmoller plot)
depthArray (float array) – depth array [m]
fieldArray (float array) – field array to plot
colorMapSectionName (str) – section name in
config
where color map info can be found.suffix (str, optional) – the suffix used for colorbar config options
colorbarLabel (str, optional) – the label for the colorbar. If plotAsContours and labelContours are both True, colorbarLabel is used as follows (typically in order to indicate the units that are associated with the contour labels): if contourComparisonFieldArray is None, the colorbarLabel string is parenthetically appended to the plot title; if contourComparisonFieldArray is not None, it is parenthetically appended to the legend entries of the contour comparison plot.
title (str, optional) – title of plot
xlabel (str, optional) – label of x- and y-axis
ylabel (str, optional) – label of x- and y-axis
figsize (tuple of float, optional) – size of the figure in inches, or None if the current figure should be used (e.g. if this is a subplot)
dpi (int, optional) – the number of dots per inch of the figure, taken from section
plot
optiondpi
in the config file by defaulttitleFontSize (int, optional) – size of the title font
titleY (float, optional) – the y value to use for placing the plot title
axisFontSize (int, optional) – size of the axis font
xLim (float array, optional) – x range of plot
yLim (float array, optional) – y range of plot
lineWidth (int, optional) – the line width of contour lines (if specified)
lineStyle (str, optional) – the line style of contour lines (if specified); this applies to the style of contour lines of fieldArray (the style of the contour lines of contourComparisonFieldArray is set using contourComparisonLineStyle).
lineColor (str, optional) – the color of contour lines (if specified); this applies to the contour lines of fieldArray (the color of the contour lines of contourComparisonFieldArray is set using contourComparisonLineColor
backgroundColor (str, optional) – the background color for the plot (NaNs will be shown in this color)
secondXAxisData (the data to use to display a second x axis (which will be) – placed above the plot). This array must have the same number of values as xArray, and it is assumed that the values in this array define locations along the x axis that are the same as those defined by the corresponding values in xArray, but in some different unit system.
secondXAxisLabel (the label for the second x axis, if requested) –
thirdXAxisData (the data to use to display a third x axis (which will be) – placed above the plot and above the second x axis, which must be specified if a third x axis is to be specified). This array must have the same number of values as xArray, and it is assumed that the values in this array define locations along the x axis that are the same as those defined by the corresponding values in xArray, but in some different unit system (which is presumably also different from the unit system used for the values in the secondXAxisData array). The typical use for this third axis is for transects, for which the primary x axis represents distance along a transect, and the second and third x axes are used to display the corresponding latitudes and longitudes.
thirdXAxisLabel (the label for the third x axis, if requested) –
numUpperTicks (the approximate number of ticks to use on the upper x axis) – or axes (these are the second and third x axes, which are placed above the plot if they have been requested by specifying the secondXAxisData or thirdXAxisData arrays above)
upperXAxisTickLabelPrecision (the number of decimal places (to the right) – of the decimal point) to use for values at upper axis ticks. This value can be adjusted (in concert with numUpperTicks) to avoid problems with overlapping numbers along the upper axis.
invertYAxis (logical, optional) – if True, invert Y axis
xArrayIsTime (logical, optional) – if True, format the x axis for time (this applies only to the primary x axis, not to the optional second or third x axes)
movingAveragePoints (int, optional) – the number of points over which to perform a moving average NOTE: this option is mostly intended for use when xArrayIsTime is True, although it will work with other data as well. Also, the moving average calculation is based on number of points, not actual x axis values, so for best results, the values in the xArray should be equally spaced.
firstYearXTicks (int, optional) – The year of the first tick on the x axis. By default, the first time entry is the first tick.
yearStrideXTicks (int, optional) – The number of years between x ticks. By default, the stride is chosen automatically to have
maxXTicks
tick marks or fewer.maxXTicks (int, optional) – the maximum number of tick marks that will be allowed along the primary x axis. This may need to be adjusted depending on the figure size and aspect ratio. NOTE: maxXTicks is only used if xArrayIsTime is True
calendar (str, optional) – the calendar to use for formatting the time axis NOTE: calendar is only used if xArrayIsTime is True
plotAsContours (bool, optional) – if plotAsContours is True, instead of plotting fieldArray as a heatmap, the function will plot only the contours of fieldArray. In addition, if contourComparisonFieldArray is not None, the contours of this field will be plotted on the same plot. The selection of contour levels is still determined as for the contours on the heatmap plots, via the ‘contours’ entry in colorMapSectionName.
contourComparisonFieldArray (float array, optional) – a comparison field array (typically observational data or results from another simulation run), assumed to be of the same shape as fieldArray, and related to xArray and depthArray in the same way fieldArray is. If contourComparisonFieldArray is None, then fieldArray will be plotted as a heatmap. However, if countourComparisonFieldArray is not None, then contours of both fieldArray and contourComparisonFieldArray will be plotted in order to enable a comparison of the two fields on the same plot. If plotAsContours is False, this parameter is ignored.
comparisonFieldName (str, optional) – the name for the comparison field. If contourComparisonFieldArray is None, this parameter is ignored.
originalFieldName (str, optional) – the name for the fieldArray field (for the purposes of labeling the contours on a contour comparison plot). If contourComparisonFieldArray is None, this parameter is ignored.
comparisonContourLineStyle (str, optional) – the line style of contour lines of the comparisonFieldName field on a contour comparison plot
comparisonContourLineColor (str, optional) – the line color of contour lines of the comparisonFieldName field on a contour comparison plot
labelContours (bool, optional) – whether or not to label contour lines (if specified) with their values
contourLabelPrecision (int, optional) – the precision (in terms of number of figures to the right of the decimal point) of contour labels
- Returns
fig (
matplotlib.figure.Figure
) – The figure that was plottedax (
matplotlib.axes.Axes
) – The subplot