mpas_analysis.shared.plot.plot_vertical_section¶
- mpas_analysis.shared.plot.plot_vertical_section(config, field, colorMapSectionName, xCoords=None, zCoord=None, triangulation_args=None, xOutline=None, zOutline=None, suffix='', colorbarLabel=None, title=None, xlabels=None, ylabel=None, figsize=(10, 4), dpi=None, titleFontSize=None, defaultFontSize=None, titleY=None, axisFontSize=None, xLim=None, yLim=None, lineWidth=2, lineStyle='solid', lineColor='black', contourColormap=None, backgroundColor='grey', invalidColor='white', outlineValid=True, numUpperTicks=None, upperXAxisTickLabelPrecision=None, invertYAxis=True, xCoordIsTime=False, movingAveragePoints=None, firstYearXTicks=None, yearStrideXTicks=None, maxXTicks=20, calendar='gregorian', plotAsContours=False, contourComparisonField=None, comparisonFieldName=None, originalFieldName=None, comparisonContourLineWidth=None, comparisonContourLineStyle=None, comparisonContourLineColor=None, labelContours=False, contourLabelPrecision=1, maxTitleLength=None)[source]¶
Plots a data set as a x distance (latitude, longitude, or spherical distance) vs depth map (vertical section).
Or, if xCoordIsTime is True, plots data set on a vertical Hovmoller plot (depth vs. time).
Typically, the
field
data are plotted using a heatmap, but ifcontourComparisonField
is not None, then contours of bothfield
andcontourComparisonField
are plotted instead.- Parameters
config (instance of ConfigParser) – the configuration, containing a [plot] section with options that control plotting
field (xarray.DataArray) – field array to plot. For contour plots,
xCoords
andzCoords
should broadcast to the same shape asfield
. For heatmap plots,xCoords
andzCoords
are the corners of the plot. If they broadcast to the same shape asfield
,field
will be bilinearly interpolated to center values for each plot cell. If the coordinates have one extra element in each direction thanfield
,field
is assumed to contain cell values and no interpolation is performed.colorMapSectionName (str) – section name in
config
where color map info can be found.xCoords (xarray.DataArray or list of xarray.DataArray, optional) – The x coordinate(s) for the
field
. Optional second and third entries will be used for a second and third x axis above the plot. The typical use for the second and 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.zCoord (xarray.DataArray, optional) – The z coordinates for the
field
triangulation_args (dict, optional) – A dict of arguments to create a matplotlib.tri.Triangulation of the transect that does not rely on it being on a logically rectangular grid. The arguments rather than the triangulation itself are passed because multiple triangulations with different masks are needed internally and there is not an obvious mechanism for copying an existing triangulation. If this option is provided,
xCoords
is only used for tick marks if more than one x axis is requested, andzCoord
will be ignored.xOutline (numpy.ndarray, optional) – pairs of points defining line segments that are used to outline the valid region of the mesh if
outlineValid = True
andtriangulation_args
is notNone
zOutline (numpy.ndarray, optional) – pairs of points defining line segments that are used to outline the valid region of the mesh if
outlineValid = True
andtriangulation_args
is notNone
- 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
contourComparisonField
is None, thecolorbarLabel
string is parenthetically appended to the plot title; ifcontourComparisonField
is not None, it is parenthetically appended to the legend entries of the contour comparison plot.- titlestr, optional
title of plot
- xlabelsstr or list of str, optional
labels of x-axes. Labels correspond to entries in
xCoords
.- ylabelstr, optional
label of 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
- defaultFontSizeint, optional
the size of text other than the title
- 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
- lineWidthfloat, 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 contourComparisonField 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 contourComparisonField is set using contourComparisonLineColor
- backgroundColorstr, optional
the background color for the plot outside the limits of
xCoord
andzCoord
.- invalidColorstr, optional
the color for invalid values (NaNs and masked areas will be shown in this color)
- outlineValidbool, optional
whether to outline the boundary between the valid an invalid regions with a black contour
- numUpperTicksint, optional
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)
- upperXAxisTickLabelPrecisionint, optional
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.
- invertYAxislogical, optional
if True, invert Y axis
- xCoordIsTimelogical, 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)
- movingAveragePointsint, optional
the number of points over which to perform a moving average NOTE: this option is mostly intended for use when
xCoordIsTime
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 first entry inxCoords
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 xCoordIsTime is True
- calendarstr, optional
the calendar to use for formatting the time axis NOTE: calendar is only used if xCoordIsTime is True
- plotAsContoursbool, optional
if plotAsContours is True, instead of plotting
field
as a heatmap, the function will plot only the contours offield
. In addition, if contourComparisonField 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 incolorMapSectionName
.- contourComparisonFieldfloat array, optional
a comparison
field
array (typically observational data or results from another simulation run), assumed to be of the same shape asfield
. IfplotAsContours
isTrue
andcountourComparisonFieldArray
is notNone
, then contours of bothfield
andcontourComparisonField
will be plotted in order to enable a comparison of the two fields on the same plot.- comparisonFieldNamestr, optional
the name for the comparison field. If contourComparisonField is None, this parameter is ignored.
- originalFieldNamestr, optional
the name for the
field
field (for the purposes of labeling the contours on a contour comparison plot). If contourComparisonField is None, this parameter is ignored.- comparisonContourLineWidthfloat, optional
the line width of contour lines of the comparisonFieldName field on a contour comparison plot
- 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
- maxTitleLengthint or None, optional
the maximum number of characters in the title, beyond which it is truncated with a trailing ellipsis. The default is from the
maxTitleLength
config option.
- Returns
fig (
matplotlib.figure.Figure
) – The figure that was plottedax (
matplotlib.axes.Axes
) – The subplot