rgbmovie#
- named_arrays.plt.rgbmovie(*TWXY, C, axis_time, axis_wavelength, ax=None, norm=None, vmin=None, vmax=None, wavelength_norm=None, wavelength_min=None, wavelength_max=None, kwargs_pcolormesh=None, **kwargs_animation)#
A convenience function that calls
pcolormovie()with the outputs fromnamed_arrays.colorsynth.rgb()and returns an animation instance and a colorbar.This allows us to plot 4D cubes, with the third dimension being represented by color, using a
pcolormovie()-like interface.- Parameters:
TWXY (AbstractArray) – The coordinates of the mesh to plot. Allowed combinations are: an instance of
named_arrays.AbstractSpectralPositionalVectorArray, an instance ofnamed_arrays.AbstractScalarand an instance ofnamed_arrays.AbstractSpectralPositionalVectorArray, two instances ofnamed_arrays.AbstractScalarand an instance ofnamed_arrays.AbstractCartesian2dVectorArray, or four instances ofnamed_arrays.AbstractScalar.C (AbstractArray) – The mesh data.
axis_time (str) – The logical axis corresponding to the different frames in the animation.
axis_wavelength (str) – The logical axis representing changing wavelength coordinate.
ax (None | Axes | AbstractArray) – The instances of
matplotlib.axes.Axesto use. IfNone, callsmatplotlib.pyplot.gca()to get the current axes. If an instance ofnamed_arrays.ScalarArray,ax.shapeshould be a subset of the broadcasted shape of*args.norm (None | Callable) – An optional function that transforms the spectral power distribution values before mapping to RGB. Equivalent to the spd_norm argument of
named_arrays.colorsynth.rgb().vmin (None | int | float | complex | ndarray | Quantity | AbstractArray) – The value of the spectral power distribution representing minimum intensity. Equivalent to the spd_min argument of
named_arrays.colorsynth.rgb().vmax (None | int | float | complex | ndarray | Quantity | AbstractArray) – The value of the spectral power distribution representing maximum intensity. Equivalent to the spd_max argument of
named_arrays.colorsynth.rgb().wavelength_norm (None | Callable) – An optional function to transform the wavelength values before they are mapped into the human visible color range.
wavelength_min (None | float | Quantity | AbstractScalar) – The wavelength value that is mapped to the minimum wavelength of the human visible color range, 380 nm.
wavelength_max (None | float | Quantity | AbstractScalar) – The wavelength value that is mapped to the maximum wavelength of the human visible color range, 700 nm
kwargs_pcolormesh (None | dict[str, Any]) – Additional keyword arguments accepted by
pcolormesh().kwargs_animation – Additional keyword arguments accepted by
matplotlib.animation.FuncAnimation.
- Return type:
tuple[FuncAnimation, FunctionArray[Cartesian2dVectorArray, AbstractScalar]]
Examples
Plot a random, 4D cube.
import matplotlib.pyplot as plt import IPython.display import astropy.units as u import astropy.visualization import named_arrays as na # Define the size of the grid shape = dict( t=3, w=11, x=16, y=16, ) # Define a simple coordinate grid t = na.linspace(0, 2, axis="t", num=shape["t"]) * u.s w = na.linspace(-1, 1, axis="w", num=shape["w"]) * u.mm x = na.linspace(-2, 2, axis="x", num=shape["x"]) * u.mm y = na.linspace(-1, 1, axis="y", num=shape["y"]) * u.mm # Define a random array of values to plot a = na.random.uniform(-1, 1, shape_random=shape) # Plot the coordinates and values using rgbmovie() astropy.visualization.quantity_support() fig, ax = plt.subplots( ncols=2, gridspec_kw=dict(width_ratios=[.9, .1]), constrained_layout=True, ) ani, colorbar = na.plt.rgbmovie( t, w, x, y, C=a, axis_time="t", axis_wavelength="w", ax=ax[0], ); na.plt.pcolormesh( C=colorbar, axis_rgb="w", ax=ax[1], ) ax[1].yaxis.tick_right() ax[1].yaxis.set_label_position("right") ani = ani.to_jshtml() plt.close(fig) IPython.display.HTML(ani)