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 bycmap
andcmap_use_series_colors
. Ifdata.dims==3
, then it is assumed thatdata
contains either RGB or RGBA data; which requires the third dimension to have length3
or4
respectively. For RGB/A data, the elements ofdata
must 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
, thendata
contains 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 insidedata
should be plotted. The units ofextent
are 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 lookupcanvas
andlabel
inseries_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, ifdata
is not an RGB/A image.cmap
must 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 insidedata
are series names. Ifcmap_use_series_colors=True
,``cmap`` is ignored. This only works for two-dimensional images as three-dimensionaldata
contains explicit colors as RGB/A values. Iflen(data.shape)=3
,cmap_use_series_colours
is 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.