Plotting Utilities (dataval.plots)

Plotting utilities.

Code author: Rasmus Handberg <rasmush@phys.au.dk>

dataval.plots.colorbar(im, ax=None, loc='right', pad=None, size='5%', label=None, ticks=None, ticklabels=None)[source]

Draw colorbar next to the given axes.

Returns:

Colorbar handle.

Return type:

matplotlib.colorbar.Colorbar

Code author: Rasmus Handberg <rasmush@phys.au.dk>

dataval.plots.plot_image(image, ax=None, scale='log', cmap=None, origin='lower', xlabel=None, ylabel=None, cbar=None, clabel='Flux ($e^{-}s^{-1}$)', cbar_ticks=None, cbar_ticklabels=None, cbar_pad=None, cbar_size='5%', title=None, percentile=95.0, vmin=None, vmax=None, offset_axes=None, color_bad='k', **kwargs)[source]

Utility function to plot a 2D image.

Parameters:
  • image (2d array) – Image data.

  • ax (matplotlib.pyplot.axes, optional) – Axes in which to plot. Default (None) is to use current active axes.

  • scale (str or astropy.visualization.ImageNormalize object, optional) – Normalization used to stretch the colormap. Options: 'linear', 'sqrt', 'log', 'asinh', 'histeq', 'sinh' and 'squared'. Can also be a astropy.visualization.ImageNormalize object. Default is 'log'.

  • origin (str, optional) – The origin of the coordinate system.

  • xlabel (str, optional) – Label for the x-axis.

  • ylabel (str, optional) – Label for the y-axis.

  • cbar (string, optional) – Location of color bar. Choises are 'right', 'left', 'top', 'bottom'. Default is not to create colorbar.

  • clabel (str, optional) – Label for the color bar.

  • cbar_size (float, optional) – Fractional size of colorbar compared to axes. Default=0.03.

  • cbar_pad (float, optional) – Padding between axes and colorbar.

  • title (str or None, optional) – Title for the plot.

  • percentile (float, optional) – The fraction of pixels to keep in color-trim. If single float given, the same fraction of pixels is eliminated from both ends. If tuple of two floats is given, the two are used as the percentiles. Default=95.

  • cmap (matplotlib colormap, optional) – Colormap to use. Default is the Blues colormap.

  • vmin (float, optional) – Lower limit to use for colormap.

  • vmax (float, optional) – Upper limit to use for colormap.

  • color_bad (str, optional) – Color to apply to bad pixels (NaN). Default is black.

  • kwargs (dict, optional) – Keyword arguments to be passed to matplotlib.pyplot.imshow().

Returns:

Image from returned

by matplotlib.pyplot.imshow().

Return type:

matplotlib.image.AxesImage

Code author: Rasmus Handberg <rasmush@phys.au.dk>

dataval.plots.plot_image_fit_residuals(fig, image, fit, residuals=None, percentile=95.0)[source]

Make a figure with three subplots showing the image, the fit and the residuals. The image and the fit are shown with logarithmic scaling and a common colorbar. The residuals are shown with linear scaling and a separate colorbar.

Parameters:
  • fig (fig object) – Figure object in which to make the subplots.

  • image (2D array) – Image numpy array.

  • fit (2D array) – Fitted image numpy array.

  • residuals (2D array, optional) – Fitted image subtracted from image numpy array.

Returns:

List with Matplotlib subplot axes objects for each subplot.

Return type:

list

dataval.plots.plots_interactive(backend=('Qt5Agg', 'MacOSX', 'Qt4Agg', 'GTK3Agg', 'Qt5Cairo', 'GTK3Cairo', 'TkAgg'))[source]

Change plotting to using an interactive backend.

Parameters:

backend (str or list) – Backend to change to. If not provided, will try different interactive backends and use the first one that works.

Code author: Rasmus Handberg <rasmush@phys.au.dk>

dataval.plots.plots_noninteractive()[source]

Change plotting to using a non-interactive backend, which can e.g. be used on a cluster. Will set backend to ‘Agg’.

Code author: Rasmus Handberg <rasmush@phys.au.dk>