erlab.interactive.colors

Functions for manipulating colors in Qt.

Module Attributes

EXCLUDED_CMAPS

Colormaps to exclude from the list of available colormaps.

Functions

color_to_QColor(c[, alpha])

Convert a matplotlib color to a PySide6.QtGui.QColor.

pg_colormap_from_name(name[, skipCache])

Get a pyqtgraph.ColorMap from its name.

pg_colormap_names([source, exclude_local])

Get all valid pyqtgraph colormap names.

pg_colormap_powernorm(cmap, gamma[, ...])

pg_colormap_to_QPixmap(cmap[, w, h, skipCache])

Convert a pyqtgraph.ColorMap to a w-by-h QPixmap thumbnail.

Classes

BetterColorBarItem([parent, image, ...])

BetterImageItem([image])

pyqtgraph.ImageItem with improved colormap support.

ColorMapComboBox(*args, **kwargs)

ColorMapGammaWidget([parent, value, ...])

class erlab.interactive.colors.BetterColorBarItem(parent=None, image=None, autoLevels=False, limits=None, pen='c', hoverPen='m', hoverBrush='#FFFFFF33', **kargs)[source]

Bases: PlotItem

addImage(image)[source]
color_changed()[source]
image_changed()[source]
image_level_changed()[source]
level_change()[source]
level_change_fin()[source]
limit_changed()[source]
mouseDragEvent(ev)[source]
removeImage(image)[source]
reset_levels()[source]
setAutoLevels(value)[source]
setImageItem(image, insert_in=None)[source]
setLimits(limits)[source]
set_dimensions(horiz_pad=None, vert_pad=None, font_size=11.0)[source]
set_width(width)[source]
property images
property levels: Sequence[float]
property limits: tuple[float, float]
property primary_image
class erlab.interactive.colors.BetterImageItem(image=None, **kwargs)[source]

Bases: ImageItem

pyqtgraph.ImageItem with improved colormap support.

Parameters:
  • image (npt.NDArray | None) – Image data

  • **kwargs – Additional arguments to pyqtgraph.ImageItem.

Signals:
  • sigColorChanged()

  • sigLimitChanged(float, float)

set_colormap(cmap, gamma, reverse=False, highContrast=False, zeroCentered=False, update=True)[source]
set_pg_colormap(cmap, update=True)[source]
class erlab.interactive.colors.ColorMapComboBox(*args, **kwargs)[source]

Bases: QComboBox

hidePopup()[source]
load_all()[source]
load_thumbnail(index)[source]
nextIndex()[source]
previousIndex()[source]
resetCmap()[source]
setDefaultCmap(cmap)[source]
setPopupMinimumWidthForItems()[source]
showPopup()[source]
LOAD_ALL_TEXT = 'Load all...'
class erlab.interactive.colors.ColorMapGammaWidget(parent=None, value=1.0, slider_cls=None, spin_cls=None)[source]

Bases: QWidget

gamma_scale(y)[source]
gamma_scale_inv(x)[source]
setValue(value)[source]
slider_changed(value)[source]
spin_changed(value)[source]
value()[source]
erlab.interactive.colors.color_to_QColor(c, alpha=None)[source]

Convert a matplotlib color to a PySide6.QtGui.QColor.

Parameters:
  • c (`ColorType <matplotlib.typing.ColorType>`) – A valid matplotlib color. See the matplotlib documentation for more information.

  • alpha (float | None) – If supplied, applies transparency to the color.

Return type:

PySide6.QtGui.QColor

erlab.interactive.colors.pg_colormap_from_name(name, skipCache=True)[source]

Get a pyqtgraph.ColorMap from its name.

Parameters:
Return type:

pyqtgraph.ColorMap

erlab.interactive.colors.pg_colormap_names(source='all', exclude_local=False)[source]

Get all valid pyqtgraph colormap names.

Parameters:

source (Literal['local', 'all', 'matplotlib']) – If 'all', includes all colorcet colormaps.

Return type:

list of str

erlab.interactive.colors.pg_colormap_powernorm(cmap, gamma, reverse=False, highContrast=False, zeroCentered=False, N=65536)[source]
erlab.interactive.colors.pg_colormap_to_QPixmap(cmap, w=64, h=16, skipCache=True)[source]

Convert a pyqtgraph.ColorMap to a w-by-h QPixmap thumbnail.

Parameters:
  • cmap (str | ColorMap) – The colormap.

  • w (int) – Specifies the dimension of the pixmap.

  • h (int) – Specifies the dimension of the pixmap.

  • skipCache (bool, optional) – Whether to skip cache, by default True. Passed onto pg_colormap_from_name().

Return type:

PySide6.QtGui.QPixmap