con#

cfplot.con(f=None, x=None, y=None, **kwargs)[source]#

Create a contour, (block)fill, or combined contour-(block)fill plot.

The minimum usage is con(f), where f is a two-dimensional array. If a CF field is passed, an appropriate plot is produced, such as a longitude-latitude or latitude-height plot. If a two-dimensional numeric array is passed, the optional x and y arrays can be used to specify the data point locations.

For two-dimensional longitude-latitude grids, blockfill defaults to a fast implementation using pcolormesh. Explicitly setting blockfill=False selects contours; vertices adjoining longitude wrap jumps are excluded to avoid stripes, leaving a narrow gap at the seam.

Parameter breakdown (see below for full detail). The following parameters:
  • set the input data to plot:
    • f, x, y

  • set the form and creation approach of plot:
    • fill, blockfill, transform_first, blockfill_fast, lines, ptype

  • configure irregular and UGRID inputs:
    • face_lons, face_lats, face_connectivity, irregular

  • configure ORCA inputs:
    • orca, orca_skip

  • configure animation rendering, frame selection and per-frame titles:
    • animation, animation_reference, animation_axis, animation_title_template

  • set the verbosity to toggle log level:
    • verbose

  • configure the axes and line appearance:
    • axes, swap_axes, linewidths, linestyles, line_labels

  • configure the colourbar:
    • colorbar_title, colorbar, colorbar_label_skip, colorbar_orientation, colorbar_shrink, colorbar_position, colorbar_fontsize, colorbar_fontweight, colorbar_text_up_down, colorbar_text_down_up, colorbar_drawedges, colorbar_fraction, colorbar_thick, colorbar_anchor, colorbar_labels

  • configure the x- and y-axes:
    • xlog, ylog, xaxis, yaxis, xticks, xticklabels, yticks, yticklabels, xlabel, ylabel

  • configure other aspects of the plot style:
    • title, titles, negative_linestyle, zero_thick, colors, alpha, zorder, nlevs, grid, level_spacing

Parameters:
  • f -- Array or CF field to plot.

  • x -- Optional x-coordinate locations of the data in f.

  • y -- Optional y-coordinate locations of the data in f.

  • fill -- If True, fill the contours with colours.

  • blockfill -- If True, produce a blockfill plot. For two-dimensional longitude-latitude grids, defaults to fast blockfill, equivalent to blockfill=True, fill=False, and blockfill_fast=True. Explicitly setting this to False selects contours and excludes vertices adjoining longitude wrap jumps to avoid stripes, leaving a narrow gap at the seam.

  • transform_first -- If True, Cartopy transforms points before calling the contouring algorithm. This can significantly improve performance because transforming points is faster than transforming patches. If unset and the number of points in the x-direction exceeds 400, this is set to True.

  • blockfill_fast -- If True, use pcolormesh for blockfill. This may be less reliable than the usual implementation but is faster for high-resolution datasets. For two-dimensional longitude-latitude grids, defaults to fast blockfill, equivalent to blockfill=True, fill=False, and blockfill_fast=True.

  • lines -- If True, draw contour lines and labels.

  • ptype --

    Plot type. Not required for CF fields. Options are:

    Value

    Plot type

    0

    No specific plot type

    1

    Longitude–latitude

    2

    Latitude–height

    3

    Longitude–height

    4

    Latitude–time

    5

    Longitude–time

    6

    Rotated pole

  • face_lons -- Longitude coordinates of face vertices.

  • face_lats -- Latitude coordinates of face vertices.

  • face_connectivity -- Connectivity information for face vertices.

  • irregular -- Flag indicating whether the data are irregular.

  • orca -- Flag indicating that the data are on an ORCA tripolar grid. If unset, cf-plot attempts to detect such grids by looking for a single discontinuity in the two-dimensional longitude array. If found, it adjusts the longitudes to remove the discontinuity.

  • orca_skip -- Plot every nth grid point in the two-dimensional longitude and latitude arrays. Useful for speeding up visualisation of high-resolution global datasets.

  • animation -- If True, enable animation-aware rendering hooks.

  • animation_reference -- Optional reference data (a cf.Field or array-like) used for automatic level generation across animation frames. When supplied and levels are automatic, contour levels are computed from this full reference rather than the current frame slice.

  • animation_axis -- Frame axis. Options are 'auto', 'T', 'Z', 'Y' and 'X'. When set to 'auto' and ptype != 0, the frame axis is inferred as a singleton axis not used by that ptype. For ptype == 0, the fallback preference is singleton T, then Z, then Y, then X.

  • animation_title_template -- Optional template used to construct per-frame titles. Available fields are {title}, {frame} and {axis}.

  • verbose -- Set to 1 to display a verbose listing of the operations performed by con.

  • axes -- If True, plot the x- and y-axes.

  • swap_axes -- If True, swap the plotted axes. Only valid for x, y, z versus t plots.

  • linewidths -- Contour line widths. Accepts a single number for all lines or an array of widths.

  • linestyles --

    Contour line styles. Options are:

    Value

    Line style

    'solid'

    Solid line

    'dashed'

    Dashed line

    'dashdot'

    Dash-dot line

    'dotted'

    Dotted line

  • line_labels -- If True, label the contour lines.

  • colorbar_title -- Title for the colour bar.

  • colorbar -- If True, add a colour bar to a filled contour plot.

  • colorbar_label_skip -- Number of colour bar labels to skip. For example, set to 2 to skip every other label.

  • colorbar_orientation -- Colour bar orientation. Options are 'horizontal' and 'vertical'. Defaults to horizontal for most plots and vertical for polar stereographic plots.

  • colorbar_shrink -- Factor by which to shrink the colour bar. If the colour bar exceeds the plot area, values such as 1.0, 0.55, or 0.5 may help it fit.

  • colorbar_position -- Colour bar position as [xmin, ymin, x_extent, y_extent] in normalised coordinates. Use this to position a common colour bar across multiple plots. For example, [0.1, 0.05, 0.8, 0.02].

  • colorbar_fontsize -- Font size for colour bar labels and title.

  • colorbar_fontweight -- Font weight for colour bar labels and title.

  • colorbar_text_up_down -- If True, alternate horizontal colour bar labels above and below the colour bar, starting above.

  • colorbar_text_down_up -- If True, alternate horizontal colour bar labels below and above the colour bar, starting below.

  • colorbar_drawedges -- If True, draw internal dividing lines in the colour bar.

  • colorbar_fraction -- Fraction of the plot area allocated to the colour bar. Defaults to 0.21 in normalised coordinates.

  • colorbar_thick -- Colour bar thickness. Defaults to 0.015 in normalised coordinates.

  • colorbar_anchor -- Anchor point of the colour bar within the fraction space. Defaults to 0.5; 0.0 places it closer to the plot and 1.0 places it further away.

  • colorbar_labels -- Labels to use for the colour bar. Defaults to the contour levels.

  • xlog -- If True, use a logarithmic x-axis.

  • ylog -- If True, use a logarithmic y-axis.

  • xaxis -- If True, plot the x-axis.

  • yaxis -- If True, plot the y-axis.

  • xticks -- Positions of the x-axis ticks.

  • xticklabels -- Labels for the x-axis ticks.

  • yticks -- Positions of the y-axis ticks.

  • yticklabels -- Labels for the y-axis ticks.

  • xlabel -- Label for the x-axis.

  • ylabel -- Label for the y-axis.

  • title -- Title for the plot.

  • titles -- If True, display a dimensions title.

  • negative_linestyle -- Line style for negative contours. Options are 'solid' and 'dashed'.

  • zero_thick -- If non-zero, draw a thicker zero contour line. For example, set to 3 to specify the line thickness.

  • colors -- Colour or sequence of colours for contour lines. Defaults to 'k'.

  • alpha -- Transparency setting. Defaults to 1.0 (fully opaque).

  • zorder -- Drawing order.

  • nlevs -- If False, let Matplotlib determine the contour levels.

  • grid -- If True, draw a grid on the map using the parameters set by cfp.setvars. Defaults are grid_x_spacing=60, grid_y_spacing=30, grid_colour='k', grid_linestyle='--', and grid_thickness=1.0.

  • level_spacing --

    Contour level spacing. Defaults to 'linear'. The available options are:

    Value

    Description

    'linear'

    Linear contour level spacing

    'log'

    Logarithmic contour level spacing

    'loglike'

    Log-like contour level spacing

    'outlier'

    Outlier-based contour level spacing

    'inspect'

    Inspect contour levels

Returns:

None.