6.2. matplotlib¶
-
scisalt.matplotlib.NonUniformImage(x, y, z, **kwargs)[source]¶ Plots a set of coordinates where:
- x and y are 1-D ndarrays of lengths N and M, respectively, specifying pixel centers
- z is an (M, N) ndarray or masked array of values to be colormapped, or a (M, N, 3) RGB array, or a (M, N, 4) RGBA array.
**kwargs can contain keywords:
- cmap for set the colormap
- alpha to set transparency
- scalex to set the x limits to available data
- scaley to set the y limits to available data
Returns class
matplotlib.image.NonUniformImage.(See http://matplotlib.org/api/image_api.html?highlight=nonuniformimage#matplotlib.image.NonUniformImage.)
-
scisalt.matplotlib.NonUniformImage_axes(img)[source]¶ Returns axes x, y for a given image img to be used with
scisalt.matplotlib.NonUniformImage().
-
scisalt.matplotlib.addlabel(ax=None, toplabel=None, xlabel=None, ylabel=None, zlabel=None, clabel=None, cb=None, windowlabel=None, fig=None, axes=None)[source]¶ Adds labels to a plot.
-
scisalt.matplotlib.axesfontsize(ax, fontsize)[source]¶ Change the font size for the title, x and y labels, and x and y tick labels for axis ax to fontsize.
-
scisalt.matplotlib.figure(title=None, **kwargs)[source]¶ Creates a figure with **kwargs with a window title title.
Returns class
matplotlib.figure.Figure.
-
scisalt.matplotlib.hist(x, bins=10, labels=None, aspect='auto', plot=True, ax=None, range=None)[source]¶ Creates a histogram of data x with a bins, labels =
[title, xlabel, ylabel].
-
scisalt.matplotlib.hist2d(x, y, bins=10, labels=None, aspect='auto', plot=True, fig=None, range=None, ax=None, interpolation='none', **kwargs)[source]¶ Creates a 2-D histogram of data x, y with bins, labels =
[title, xlabel, ylabel], aspect ration aspect. Attempts to use axis ax first, then the current axis of fig, then the last axis, to use an already-created window.Plotting (plot) is on by default, setting false doesn’t attempt to create a figure.
interpolation sets the interpolation type of
matplotlib.axis.imshow().Returns a handle and extent as
h, extent
-
scisalt.matplotlib.imshow_batch(images, cbar=True, show=True, pdf=None, figsize=(16, 12), rows=2, columns=2, cmap=None, **kwargs)[source]¶ Plots an array of images to a single window of size figsize with rows and columns.
- cmap: Specifies color map
- cbar: Add color bars
- show: If false, dismisses each window after is created and optionally saved
- pdf: Save to a pdf of filename pdf
- **kwargs passed to
matplotlib.axis.imshow
-
class
scisalt.matplotlib.imshow_slider(image, **kwargs)[source]¶ Convenience class for viewing images.
Plots image to a to an instance of
matplotlib.axis.imshow(**kwargs), with sliders for controlling bounds.-
clim_max¶ Slider value for maximum
-
clim_min¶ Slider value for minimum
-
imgmax¶ Maximum of color bar
-
imgmin¶ Minimum of color bar
-
-
scisalt.matplotlib.less_labels(ax, x_fraction=0.5, y_fraction=0.5)[source]¶ Scale the number of tick labels in x and y by x_fraction and y_fraction respectively.
-
scisalt.matplotlib.pcolor_axes(array, px_to_units=<function px_to_units>)[source]¶ Return axes
x, yfor array to be used withmatplotlib.pyplot.color().px_to_units is a function to convert pixels to units. By default, returns pixels.
-
scisalt.matplotlib.plot_featured(*args, **kwargs)[source]¶ Wrapper for matplotlib.pyplot.plot() / errorbar().
Takes options:
- ‘error’: if true, use
matplotlib.pyplot.errorbar()instead ofmatplotlib.pyplot.plot(). *args and **kwargs passed through here. - ‘fig’: figure to use.
- ‘figlabel’: figure label.
- ‘legend’: legend location.
- ‘toplabel’: top label of plot.
- ‘xlabel’: x-label of plot.
- ‘ylabel’: y-label of plot.
- ‘error’: if true, use
-
scisalt.matplotlib.savefig(filename, path='figs', fig=None, ext='eps', **kwargs)[source]¶ Save the figure fig (optional, if not specified, latest figure in focus) to filename in the path path with extension ext.
**kwargs is passed to
matplotlib.figure.Figure.savefig().
-
scisalt.matplotlib.setup_figure(gridspec_x=1, gridspec_y=1)[source]¶ Returns
fig, gs:- fig:
matplotlib.figure.Figureinstance - gs:
matplotlib.gridspec.GridSpecinstance with gridspec_x rows and gridspec_y columns
- fig:
-
scisalt.matplotlib.showfig(fig, aspect='auto')[source]¶ Shows a figure with a typical orientation so that x and y axes are set up as expected.
-
scisalt.matplotlib.tile()¶ Tile open figures. Finnicky on various OS’s, so not imported by default.