iris.plot

Iris-specific extensions to matplotlib, mimicking the matplotlib.pyplot interface.

See also: matplotlib.

In this module:

iris.plot.barbs(u_cube, v_cube, *args, **kwargs)[source]

Draws a barb plot from two vector component cubes. Triangles, full-lines and half-lines represent increments of 50, 10 and 5 respectively.

Args:

  • u_cube, v_cube(Cube)

    u and v vector components. Must have same shape and units. If the cubes have geographic coordinates, the values are treated as true distance differentials, e.g. windspeeds, and not map coordinate vectors. The components are aligned with the North and East of the cube coordinate system.

Note

At present, if u_cube and v_cube have geographic coordinates, then they must be in a lat-lon coordinate system, though it may be a rotated one. To transform wind values between coordinate systems, use iris.analysis.cartography.rotate_grid_vectors(). To transform coordinate grid points, you will need to create 2-dimensional arrays of x and y values. These can be transformed with cartopy.crs.CRS.transform_points().

Kwargs:

  • coords: (list of Coord or string)

    Coordinates or coordinate names. Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • axes: the matplotlib.axes.Axes to use for drawing.

    Defaults to the current axes if none provided.

See matplotlib.pyplot.barbs() for details of other valid keyword arguments.

↑ top ↑

iris.plot.citation(text, figure=None, axes=None)[source]

Add a text citation to a plot.

Places an anchored text citation in the bottom right hand corner of the plot.

Args:

  • text: str

    Citation text to be plotted.

Kwargs:

↑ top ↑

iris.plot.contour(cube, *args, **kwargs)[source]

Draws contour lines based on the given Cube.

Kwargs:

  • coords: list of Coord objects or coordinate names

    Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

See matplotlib.pyplot.contour() for details of other valid keyword arguments.

↑ top ↑

iris.plot.contourf(cube, *args, **kwargs)[source]

Draws filled contours based on the given Cube.

Kwargs:

  • coords: list of Coord objects or coordinate names

    Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

See matplotlib.pyplot.contourf() for details of other valid keyword arguments.

↑ top ↑

iris.plot.default_projection(cube)[source]

Return the primary map projection for the given cube.

Using the returned projection, one can create a cartopy map with:

import matplotlib.pyplot as plt
ax = plt.ax(projection=default_projection(cube))

↑ top ↑

iris.plot.default_projection_extent(cube, mode=0)[source]

Return the cube’s extents (x0, x1, y0, y1) in its default projection.

Keyword arguments:

  • mode: Either iris.coords.POINT_MODE or iris.coords.BOUND_MODE

    Triggers whether the extent should be representative of the cell points, or the limits of the cell’s bounds. The default is iris.coords.POINT_MODE.

↑ top ↑

iris.plot.orography_at_bounds(cube, facecolor='#888888', coords=None, axes=None)[source]

Plots orography defined at cell boundaries from the given Cube.

↑ top ↑

iris.plot.orography_at_points(cube, facecolor='#888888', coords=None, axes=None)[source]

Plots orography defined at sample points from the given Cube.

↑ top ↑

iris.plot.outline(cube, coords=None, color='k', linewidth=None, axes=None)[source]

Draws cell outlines based on the given Cube.

Kwargs:

  • coords: list of Coord objects or coordinate names

    Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • color: None or mpl color

    The color of the cell outlines. If None, the matplotlibrc setting patch.edgecolor is used by default.

  • linewidth: None or number

    The width of the lines showing the cell outlines. If None, the default width in patch.linewidth in matplotlibrc is used.

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

↑ top ↑

iris.plot.pcolor(cube, *args, **kwargs)[source]

Draws a pseudocolor plot based on the given 2-dimensional Cube.

The cube must have either two 1-dimensional coordinates or two 2-dimensional coordinates with contiguous bounds to plot the cube against.

Kwargs:

  • coords: list of Coord objects or coordinate names

    Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

  • contiguity_tolerance: float

    The absolute tolerance used when checking for contiguity between the bounds of the cells. Defaults to None.

See matplotlib.pyplot.pcolor() for details of other valid keyword arguments.

↑ top ↑

iris.plot.pcolormesh(cube, *args, **kwargs)[source]

Draws a pseudocolor plot based on the given 2-dimensional Cube.

The cube must have either two 1-dimensional coordinates or two 2-dimensional coordinates with contiguous bounds to plot against each other.

Kwargs:

  • coords: list of Coord objects or coordinate names

    Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

  • contiguity_tolerance: float

    The absolute tolerance used when checking for contiguity between the bounds of the cells. Defaults to None.

See matplotlib.pyplot.pcolormesh() for details of other valid keyword arguments.

↑ top ↑

iris.plot.plot(*args, **kwargs)[source]

Draws a line plot based on the given cube(s) or coordinate(s).

The first one or two arguments may be cubes or coordinates to plot. Each of the following is valid:

# plot a 1d cube against its dimension coordinate
plot(cube)

# plot a 1d coordinate
plot(coord)

# plot a 1d cube against a given 1d coordinate, with the cube
# values on the y-axis and the coordinate on the x-axis
plot(coord, cube)

# plot a 1d cube against a given 1d coordinate, with the cube
# values on the x-axis and the coordinate on the y-axis
plot(cube, coord)

# plot two 1d coordinates against one-another
plot(coord1, coord2)

# plot two 1d cubes against one-another
plot(cube1, cube2)

Kwargs:

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

See matplotlib.pyplot.plot() for details of additional valid keyword arguments.

↑ top ↑

iris.plot.points(cube, *args, **kwargs)[source]

Draws sample point positions based on the given Cube.

Kwargs:

  • coords: list of Coord objects or coordinate names

    Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

See matplotlib.pyplot.scatter() for details of other valid keyword arguments.

↑ top ↑

iris.plot.quiver(u_cube, v_cube, *args, **kwargs)[source]

Draws an arrow plot from two vector component cubes.

Args:

  • u_cube, v_cubeCube

    u and v vector components. Must have same shape and units. If the cubes have geographic coordinates, the values are treated as true distance differentials, e.g. windspeeds, and not map coordinate vectors. The components are aligned with the North and East of the cube coordinate system.

Note

At present, if u_cube and v_cube have geographic coordinates, then they must be in a lat-lon coordinate system, though it may be a rotated one. To transform wind values between coordinate systems, use iris.analysis.cartography.rotate_grid_vectors(). To transform coordinate grid points, you will need to create 2-dimensional arrays of x and y values. These can be transformed with cartopy.crs.CRS.transform_points().

Kwargs:

  • coords: list of Coord or string

    Coordinates or coordinate names. Use the given coordinates as the axes for the plot. The order of the given coordinates indicates which axis to use for each, where the first element is the horizontal axis of the plot and the second element is the vertical axis of the plot.

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

See matplotlib.pyplot.quiver() for details of other valid keyword arguments.

↑ top ↑

iris.plot.scatter(x, y, *args, **kwargs)[source]

Draws a scatter plot based on the given cube(s) or coordinate(s).

Args:

  • x: Cube or Coord

    A cube or a coordinate to plot on the x-axis.

  • y: Cube or Coord

    A cube or a coordinate to plot on the y-axis.

Kwargs:

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

See matplotlib.pyplot.scatter() for details of additional valid keyword arguments.

↑ top ↑

iris.plot.symbols(x, y, symbols, size, axes=None, units='inches')[source]

Draws fixed-size symbols.

See iris.symbols for available symbols.

Args:

  • x: iterable

    The x coordinates where the symbols will be plotted.

  • y: iterable

    The y coordinates where the symbols will be plotted.

  • symbols: iterable

    The symbols (from iris.symbols) to plot.

  • size: float

    The symbol size in units.

Kwargs:

  • axes: matplotlib.axes.Axes

    The axes to use for drawing. Defaults to the current axes if none provided.

  • units: [‘inches’, ‘points’]

    The unit for the symbol size.

↑ top ↑

PlotDefn(coords, transpose)

class iris.plot.PlotDefn(_cls, coords, transpose)

Create new instance of PlotDefn(coords, transpose)

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

coords

Alias for field number 0

transpose

Alias for field number 1