Note
This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.
MplDrawer.image¶
- MplDrawer.image(data, extent=None, name=None, label=None, cmap=None, cmap_use_series_colors=False, colorbar=False, **options)[source]¶
Draw an image of numerical values, series names, or RGB/A values.
- Parameters:
data (
ndarray) – The two-/three-dimensional data defining an image. Ifdata.dims==2, then the pixel colors are determined bycmapandcmap_use_series_colors. Ifdata.dims==3, then it is assumed thatdatacontains either RGB or RGBA data; which requires the third dimension to have length3or4respectively. For RGB/A data, the elements ofdatamust be floats or integers in the range 0-1 and 0-255 respectively. If the data is two-dimensional, there is no limit on the range of the values if they are numerical. Ifcmap_use_series_colors=True, thendatacontains series names; which can be strings or numerical values, as long as they are appropriate series names.extent (
Optional[Tuple[float,float,float,float]]) – An optional tuple(x_min, x_max, y_min, y_max)which defines a rectangular region within which the values insidedatashould be plotted. The units ofextentare the same as those of the X and Y axes for the axis. If None, the extent of the image is taken as(0, data.shape[0], 0, data.shape[1]). Default is None.name (
Union[str,int,float,None]) – Name of this image. Used to lookupcanvasandlabelinseries_params.label (
Optional[str]) – An optional label for the colorbar, ifcolorbar=True.cmap (
Union[str,Any,None]) – Optional colormap for assigning colors to the image values, ifdatais not an RGB/A image.cmapmust be a string or object instance which is recognized by the drawer. Defaults to None.cmap_use_series_colors (
bool) – Whether to assign colors to the image based on series colors, where the values insidedataare series names. Ifcmap_use_series_colors=True,``cmap`` is ignored. This only works for two-dimensional images as three-dimensionaldatacontains explicit colors as RGB/A values. Iflen(data.shape)=3,cmap_use_series_coloursis ignored. Defaults to False.colorbar (
bool) – Whether to add a bar showing the color-value mapping for the image. Defaults to False.options – Valid options for the drawer backend API.