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, N=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
- configinstance of ConfigParser
the configuration, containing a [plot] section with options that control plotting
- xArrayfloat array
x array (latitude, longitude, or spherical distance; or, time for a Hovmoller plot)
- depthArrayfloat array
depth array [m]
- fieldArrayfloat array
field array to plot
- colorMapSectionNamestr
section name in
config
where color map info can be found.- suffixstr, optional
the suffix used for colorbar config options
- colorbarLabelstr, 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.
- titlestr, optional
title of plot
- xlabel, ylabelstr, optional
label of x- and y-axis
- figsizetuple 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)
- dpiint, optional
the number of dots per inch of the figure, taken from section
plot
optiondpi
in the config file by default- titleFontSizeint, optional
size of the title font
- titleYfloat, optional
the y value to use for placing the plot title
- axisFontSizeint, optional
size of the axis font
- xLimfloat array, optional
x range of plot
- yLimfloat array, optional
y range of plot
- lineWidthint, optional
the line width of contour lines (if specified)
- lineStylestr, 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).
- lineColorstr, 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
- backgroundColorstr, optional
the background color for the plot (NaNs will be shown in this color)
- secondXAxisDatathe 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.
- secondXAxisLabelthe label for the second x axis, if requested
- thirdXAxisDatathe 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.
- thirdXAxisLabelthe label for the third x axis, if requested
- numUpperTicksthe 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)
- upperXAxisTickLabelPrecisionthe 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.
- invertYAxislogical, optional
if True, invert Y axis
- xArrayIsTimelogical, 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)
- Nint, 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.
- firstYearXTicksint, optional
The year of the first tick on the x axis. By default, the first time entry is the first tick.
- yearStrideXTicksint, optional
The number of years between x ticks. By default, the stride is chosen automatically to have
maxXTicks
tick marks or fewer.- maxXTicksint, 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
- calendarstr, optional
the calendar to use for formatting the time axis NOTE: calendar is only used if xArrayIsTime is True
- plotAsContoursbool, 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.
- contourComparisonFieldArrayfloat 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.
- comparisonFieldNamestr, optional
the name for the comparison field. If contourComparisonFieldArray is None, this parameter is ignored.
- originalFieldNamestr, 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.
- comparisonContourLineStylestr, optional
the line style of contour lines of the comparisonFieldName field on a contour comparison plot
- comparisonContourLineColorstr, optional
the line color of contour lines of the comparisonFieldName field on a contour comparison plot
- labelContoursbool, optional
whether or not to label contour lines (if specified) with their values
- contourLabelPrecisionint, 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 plotted
- ax
matplotlib.axes.Axes
The subplot
- fig