PixelMap
eitprocessing.plotting.pixelmap.PixelMapPlotting
dataclass
¶
Utility class for plotting pixel maps and masks.
imshow
¶
imshow(
colorbar: bool | None = None,
normalize: bool | None = None,
percentage: bool | None = None,
absolute: bool | None = None,
colorbar_kwargs: dict | None = None,
facecolor: ColorType | None = None,
hide_axes: bool | None = None,
**kwargs
) -> AxesImage
Display the pixel map or mask using imshow
.
This method is a wrapper around matplotlib.pyplot.imshow
that provides convenient defaults and formatting
options for displaying pixel maps and masks.
Plotting configuration is taken from plot_config
, unless overridden by explicit arguments. Any additional
keyword arguments are merged with plot_config.extra_kwargs
and passed to matplotlib.pyplot.imshow
.
If colorbar
is True, a colorbar is added to the axes. If normalize
is True, the pixel values are scaled
by their maximum value before plotting. The appearance of the colorbar can be modified using percentage
and
absolute
flags:
percentage=True
displays the colorbar in percentage units (where 1.0 → 100%).absolute=True
uses the absolute value of the data for color scaling and labeling.
If the colormap has underflow or overflow colors (e.g., for negative values), the colorbar will extend
accordingly. Additional arguments can be passed to control or override the appearance of the colorbar via
colorbar_kwargs
, which are passed directly to matplotlib.pyplot.colorbar
.
If hide_axes
is True, the axis ticks and labels are hidden (but the axes remain visible to retain background
styling such as facecolor).
Additional keyword arguments are passed directly to imshow
, allowing for full control over image rendering.
Notably, you can pass an existing matplotlib Axes object using the ax
keyword argument.
PARAMETER | DESCRIPTION |
---|---|
colorbar
|
Whether to display a colorbar.
TYPE:
|
normalize
|
Whether to scale by the maximum value.
TYPE:
|
percentage
|
Whether to display the colorbar values as a percentage.
TYPE:
|
absolute
|
Whether to display the colorbar using absolute values.
TYPE:
|
colorbar_kwargs
|
Additional arguments passed to
TYPE:
|
facecolor
|
Background color for the axes. If None, uses the facecolor of the PixelMap.
TYPE:
|
hide_axes
|
Whether to hide the axes ticks and labels.
TYPE:
|
ax
|
Axes to plot on. If not provided, uses the current axes.
TYPE:
|
**kwargs
|
Additional keyword arguments passed to
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
AxesImage
|
The image object created by imshow.
TYPE:
|
contour
¶
Create a contour plot of the pixel map or mask.
This method uses matplotlib.pyplot.contour
to create a contour plot of the pixel map values.
PARAMETER | DESCRIPTION |
---|---|
**kwargs
|
Additional keyword arguments passed to
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
QuadContourSet
|
The contour set created by the contour function.
TYPE:
|
surface
¶
Create a 3D surface plot of the pixel map or mask.
This method uses matplotlib.pyplot.axes3d.plot_surface
to create a 3D surface plot of the pixel map values.
PARAMETER | DESCRIPTION |
---|---|
**kwargs
|
Additional keyword arguments passed to
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
Axes3D
|
The 3D axes object containing the surface plot.
TYPE:
|
add_region_markers
¶
Add markers to an integer map plot.
This methods adds text labels at the center of all pixels with the same label, assuming continuous regions where
the center of mass is inside the region itself. If the regions are not continuous, the label is placed in the
largest region. If the center of mass of the region is outside the region, the label position is determined by
repeatedly eroding the region (using scipy.ndimage.erosion
).
By default, the text labels are the integer values converted to strings. You can customize labels by providing a
dictionary label_map
, mapping the integer values to custom labels.
Center of mass
For any regular shape, the center of mass is near the geometrical center of a region. However, for e.g. a C-shaped region, the center of mass might fall outside the region itself.
PARAMETER | DESCRIPTION |
---|---|
ax
|
The axes to add the markers to.
TYPE:
|
label_map
|
A dictionary mapping integer labels to string labels. If None, the integer label itself is used.
TYPE:
|
**kwargs
|
Additional keyword arguments passed to the text function, such as
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
list[Text]
|
list[mpl.text.Text]: A list of text objects created for the labels. |