scico.plot#

Plotting/visualization functions.

Optional alternative high-level interface to selected matplotlib plotting functions.

Functions

close([fig])

Close figure(s).

config_notebook_plotting()

Configure plotting functions for inline plotting.

contour(z[, x, y, v, xlog, ylog, xlbl, ...])

Contour plot of a 2D surface.

imview(img[, title, copy, fltscl, intrp, ...])

Display an image.

plot(y[, x, ptyp, xlbl, ylbl, title, lgnd, lglc])

Plot points or lines in 2D.

set_ipython_plot_backend([backend])

Set matplotlib backend within an ipython shell.

set_notebook_plot_backend([backend])

Set matplotlib backend within a Jupyter Notebook shell.

surf(z[, x, y, elev, azim, xlbl, ylbl, ...])

Plot a 2D surface in 3D.

scico.plot.plot(y, x=None, ptyp='plot', xlbl=None, ylbl=None, title=None, lgnd=None, lglc=None, **kwargs)[source]#

Plot points or lines in 2D.

Plot points or lines in 2D. If a figure object is specified then the plot is drawn in that figure, and fig.show() is not called. The figure is closed on key entry ‘q’.

Parameters:
  • y (array_like) – 1d or 2d array of data to plot. If a 2d array, each column is plotted as a separate curve.

  • x (array_like, optional (default None)) – Values for x-axis of the plot.

  • ptyp (string, optional (default 'plot')) – Plot type specification (options are ‘plot’, ‘semilogx’, ‘semilogy’, and ‘loglog’).

  • xlbl (string, optional (default None)) – Label for x-axis.

  • ylbl (string, optional (default None)) – Label for y-axis.

  • title (string, optional (default None)) – Figure title.

  • lgnd (list of strings, optional (default None)) – List of legend string.

  • lglc (string, optional (default None)) – Legend location string.

  • **kwargs

    matplotlib.lines.Line2D properties or figure properties.

    Keyword arguments specifying matplotlib.lines.Line2D properties, e.g. lw=2.0 sets a line width of 2, or properties of the figure and axes. If not specified, the defaults for line width (lw) and marker size (ms) are 1.5 and 6.0 respectively. The valid figure and axes keyword arguments are listed below:

    kwarg

    Accepts

    Description

    fgsz

    tuple (width,height)

    Specify figure dimensions in inches

    fgnm

    integer

    Figure number of figure

    fig

    matplotlib.figure.Figure object

    Draw in specified figure instead of creating one

    ax

    matplotlib.axes.Axes object

    Plot in specified axes instead of current axes of figure

Returns:

Raises:

ValueError – If an invalid plot type is specified via parameter ptyp.

scico.plot.surf(z, x=None, y=None, elev=None, azim=None, xlbl=None, ylbl=None, zlbl=None, title=None, lblpad=8.0, alpha=1.0, cntr=None, cmap=None, fgsz=None, fgnm=None, fig=None, ax=None)[source]#

Plot a 2D surface in 3D.

Plot a 2D surface in 3D. If a figure object is specified then the surface is drawn in that figure, and fig.show() is not called. The figure is closed on key entry ‘q’.

Parameters:
  • z (array_like) – 2d array of data to plot.

  • x (array_like, optional (default None)) – Values for x-axis of the plot.

  • y (array_like, optional (default None)) – Values for y-axis of the plot.

  • elev (float) – Elevation angle (in degrees) in the z plane.

  • azim (float) – Azimuth angle (in degrees) in the x,y plane.

  • xlbl (string, optional (default None)) – Label for x-axis.

  • ylbl (string, optional (default None)) – Label for y-axis.

  • zlbl (string, optional (default None)) – Label for z-axis.

  • title (string, optional (default None)) – Figure title.

  • lblpad (float, optional (default 8.0)) – Label padding.

  • alpha (float between 0.0 and 1.0, optional (default 1.0)) – Transparency.

  • cntr (int or sequence of ints, optional (default None)) – If not None, plot contours of the surface on the lower end of the z-axis. An int specifies the number of contours to plot, and a sequence specifies the specific contour levels to plot.

  • cmap (matplotlib.colors.Colormap object, optional (default None)) – Color map for surface. If none specifed, defaults to cm.YlOrRd.

  • fgsz (tuple (width,height), optional (default None)) – Specify figure dimensions in inches.

  • fgnm (integer, optional (default None)) – Figure number of figure.

  • fig (matplotlib.figure.Figure object, optional (default None)) – Draw in specified figure instead of creating one.

  • ax (matplotlib.axes.Axes object, optional (default None)) – Plot in specified axes instead of creating one.

Returns:

scico.plot.contour(z, x=None, y=None, v=5, xlog=False, ylog=False, xlbl=None, ylbl=None, title=None, cfmt=None, cfntsz=10, lfntsz=None, alpha=1.0, cmap=None, vmin=None, vmax=None, fgsz=None, fgnm=None, fig=None, ax=None)[source]#

Contour plot of a 2D surface.

Contour plot of a 2D surface. If a figure object is specified then the plot is drawn in that figure, and fig.show() is not called. The figure is closed on key entry ‘q’.

Parameters:
  • z (array_like) – 2d array of data to plot.

  • x (array_like, optional (default None)) – Values for x-axis of the plot.

  • y (array_like, optional (default None)) – Values for y-axis of the plot.

  • v (int or sequence of floats, optional (default 5)) – An int specifies the number of contours to plot, and a sequence specifies the specific contour levels to plot.

  • xlog (boolean, optional (default False)) – Set x-axis to log scale.

  • ylog (boolean, optional (default False)) – Set y-axis to log scale.

  • xlbl (string, optional (default None)) – Label for x-axis.

  • ylbl (string, optional (default None)) – Label for y-axis.

  • title (string, optional (default None)) – Figure title.

  • cfmt (string, optional (default None)) – Format string for contour labels.

  • cfntsz (int or None, optional (default 10)) – Contour label font size. No contour labels are displayed if set to 0 or None.

  • lfntsz (int, optional (default None)) – Axis label font size. The default font size is used if set to None.

  • alpha (float, optional (default 1.0)) – Underlying image display alpha value.

  • cmap (matplotlib.colors.Colormap, optional (default None)) – Color map for surface. If none specifed, defaults to cm.YlOrRd.

  • vmin (float, optional (default None)) – Set upper and lower bounds for the color map (see the corresponding parameters of matplotlib.axes.Axes.imshow).

  • vmax (float, optional (default None)) – Set upper and lower bounds for the color map (see the corresponding parameters of matplotlib.axes.Axes.imshow).

  • fgsz (tuple (width,height), optional (default None)) – Specify figure dimensions in inches.

  • fgnm (integer, optional (default None)) – Figure number of figure.

  • fig (matplotlib.figure.Figure object, optional (default None)) – Draw in specified figure instead of creating one.

  • ax (matplotlib.axes.Axes object, optional (default None)) – Plot in specified axes instead of current axes of figure.

Returns:

scico.plot.imview(img, title=None, copy=True, fltscl=False, intrp='nearest', norm=None, cbar=False, cmap=None, fgsz=None, fgnm=None, fig=None, ax=None)[source]#

Display an image.

Display an image. Pixel values are displayed when the pointer is over valid image data. If a figure object is specified then the image is drawn in that figure, and fig.show() is not called. The figure is closed on key entry ‘q’.

Parameters:
  • img (array_like, shape (Nr, Nc) or (Nr, Nc, 3) or (Nr, Nc, 4)) – Image to display.

  • title (string, optional (default None)) – Figure title.

  • copy (boolean, optional (default True)) – If True, create a copy of input img as a reference for displayed pixel values, ensuring that displayed values do not change when the array changes in the calling scope. Set this flag to False if the overhead of an additional copy of the input image is not acceptable.

  • fltscl (boolean, optional (default False)) – If True, rescale and shift floating point arrays to [0,1].

  • intrp (string, optional (default 'nearest')) – Specify type of interpolation used to display image (see interpolation parameter of matplotlib.axes.Axes.imshow).

  • norm (matplotlib.colors.Normalize object, optional (default None)) – Specify the matplotlib.colors.Normalize instance used to scale pixel values for input to the color map.

  • cbar (boolean, optional (default False)) – Flag indicating whether to display colorbar.

  • cmap (matplotlib.colors.Colormap, optional (default None)) – Color map for image. If none specifed, defaults to cm.Greys_r for monochrome image.

  • fgsz (tuple (width,height), optional (default None)) – Specify figure dimensions in inches.

  • fgnm (integer, optional (default None)) – Figure number of figure.

  • fig (matplotlib.figure.Figure object, optional (default None)) – Draw in specified figure instead of creating one.

  • ax (matplotlib.axes.Axes object, optional (default None)) – Plot in specified axes instead of current axes of figure.

Returns:

Raises:

ValueError – If the input array is not of the required shape.

scico.plot.close(fig=None)[source]#

Close figure(s).

Close figure(s). If a figure object reference or figure number is provided, close the specified figure, otherwise close all figures.

Parameters:

fig (matplotlib.figure.Figure object or integer (optional (default None)) – Figure object or number of figure to close.

scico.plot.set_ipython_plot_backend(backend='qt')[source]#

Set matplotlib backend within an ipython shell.

Set matplotlib backend within an ipython shell. This function has the same effect as the line magic %matplotlib [backend] but is called as a function and includes a check to determine whether the code is running in an ipython shell, so that it can safely be used within a normal python script since it has no effect when not running in an ipython shell.

Parameters:

backend (string, optional (default 'qt')) – Name of backend to be passed to the %matplotlib line magic command.

scico.plot.set_notebook_plot_backend(backend='inline')[source]#

Set matplotlib backend within a Jupyter Notebook shell.

Set matplotlib backend within a Jupyter Notebook shell. This function has the same effect as the line magic %matplotlib [backend] but is called as a function and includes a check to determine whether the code is running in a notebook shell, so that it can safely be used within a normal python script since it has no effect when not running in a notebook shell.

Parameters:

backend (string, optional (default 'inline')) – Name of backend to be passed to the %matplotlib line magic command.

scico.plot.config_notebook_plotting()[source]#

Configure plotting functions for inline plotting.

Configure plotting functions for inline plotting within a Jupyter Notebook shell. This function has no effect when not within a notebook shell, and may therefore be used within a normal python script.