scico.plot#
Plotting/visualization functions.
Optional alternative high-level interface to selected matplotlib
plotting functions.
Functions
|
Close figure(s). |
Configure plotting functions for inline plotting. |
|
|
Contour plot of a 2D surface. |
|
Display an image. |
|
Plot points or lines in 2D. |
|
Set matplotlib backend within an ipython shell. |
|
Set matplotlib backend within a Jupyter Notebook shell. |
|
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
objectDraw in specified figure instead of creating one
ax
matplotlib.axes.Axes
objectPlot in specified axes instead of current axes of figure
- Returns:
fig (
matplotlib.figure.Figure
object) – Figure object for this figure.ax (
matplotlib.axes.Axes
object): Axes object for this plot.
- 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 notNone
, 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 (defaultNone
)) – 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 (defaultNone
)) – Draw in specified figure instead of creating one.ax (
matplotlib.axes.Axes
object, optional (defaultNone
)) – Plot in specified axes instead of creating one.
- Returns:
fig (
matplotlib.figure.Figure
object) – Figure object for this figure.ax (
matplotlib.axes.Axes
object): Axes object for this plot.
- 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 orNone
.lfntsz (int, optional (default
None
)) – Axis label font size. The default font size is used if set toNone
.alpha (float, optional (default 1.0)) – Underlying image display alpha value.
cmap (
matplotlib.colors.Colormap
, optional (defaultNone
)) – 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 ofmatplotlib.axes.Axes.imshow
).vmax (float, optional (default
None
)) – Set upper and lower bounds for the color map (see the corresponding parameters ofmatplotlib.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 (defaultNone
)) – Draw in specified figure instead of creating one.ax (
matplotlib.axes.Axes
object, optional (defaultNone
)) – Plot in specified axes instead of current axes of figure.
- Returns:
fig (
matplotlib.figure.Figure
object) – Figure object for this figure.ax (
matplotlib.axes.Axes
object): Axes object for this plot.
- 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
)) – IfTrue
, 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 toFalse
if the overhead of an additional copy of the input image is not acceptable.fltscl (boolean, optional (default
False
)) – IfTrue
, 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 (defaultNone
)) – Specify thematplotlib.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 (defaultNone
)) – 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 (defaultNone
)) – Draw in specified figure instead of creating one.ax (
matplotlib.axes.Axes
object, optional (defaultNone
)) – Plot in specified axes instead of current axes of figure.
- Returns:
fig (
matplotlib.figure.Figure
object) – Figure object for this figure.ax (
matplotlib.axes.Axes
object): Axes object for this plot.
- 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 (defaultNone
)) – 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.