psy_simple.widgets.colors module

Module for color specific widgets

This module corresponds to the psy_simple.colors module as a version for the usage in the psyplot GUI.

Classes:

ArrayFmtWidget(parent[, array])

Fmt widget for psy_simple.plotters.DataTicksCalculator

BackGroundColorWidget(parent, fmto, project)

The widget to select the axes background color

BoundsFmtWidget(parent, fmto, project[, ...])

The widget for modifying the psy_simple.plotters.Bounds fmt

CMapFmtWidget(parent, fmto, project[, ...])

The widget for modifying the psy_simple.plotters.CMap fmt

CTicksFmtWidget(parent, fmto, project[, ...])

The formatoptions widget for the colorbar ticks.

CmapButton([cmaps, current])

A button with a dropdown menu to select colormaps

ColorLabel([color])

A QTableWidget with one cell and no headers to just display a color

ColormapDialog([names, N, editable])

A widget for selecting a colormap

ColormapModel([names, N])

A model for displaying colormaps

ColormapTable([names, N, editable])

A table for displaying colormaps

DataTicksCalculatorFmtWidget(parent[, ...])

Fmt widget for psy_simple.plotters.DataTicksCalculator

HighlightWidget

NormalizationWidget(parent, norm)

A simple widget representing a boundary norm

Functions:

create_cmap_thumb(cmap[, output])

class psy_simple.widgets.colors.ArrayFmtWidget(parent, array=None)[source]

Bases: PyQt5.QtWidgets.QWidget

Fmt widget for psy_simple.plotters.DataTicksCalculator

This formatoption widgets contains 3 line edits, one for the minimum, one for the maximum and one for the step size. And a spin box for the number of increments

Methods:

get_decimals(vmin, vmax)

set_array(*args, **kwargs)

set_obj()

toggle_txt_step(s)

static get_decimals(vmin, vmax)[source]
set_array(*args, **kwargs)[source]
set_obj()[source]
toggle_txt_step(s)[source]
class psy_simple.widgets.colors.BackGroundColorWidget(parent, fmto, project)[source]

Bases: PyQt5.QtWidgets.QWidget

The widget to select the axes background color

Methods:

set_color(color)

set_transparent()

toggle_color_button()

set_color(color)[source]
set_transparent()[source]
toggle_color_button()[source]
class psy_simple.widgets.colors.BoundsFmtWidget(parent, fmto, project, properties=True)[source]

Bases: PyQt5.QtWidgets.QWidget

The widget for modifying the psy_simple.plotters.Bounds fmt

Methods:

block_widgets(*widgets)

get_auto_discrete_array_widget()

get_discrete_array_widget()

get_norm_widget(norm)

refresh_current_widget()

refresh_methods(text)

set_obj(obj)

set_value(value)

Attributes:

current_widget

default_args

default_kws

methods

norm_map

Classes:

methods_type

alias of psy_simple.plugin.BoundsType

block_widgets(*widgets)[source]
current_widget = None
default_args = {'power-law': [1.0], 'symlog': [0.001]}
default_kws = {'symlog': {'base': 10}}
get_auto_discrete_array_widget()[source]
get_discrete_array_widget()[source]
get_norm_widget(norm)[source]
methods = ['Discrete', 'Continuous']
methods_type

alias of psy_simple.plugin.BoundsType Attributes:

N

percmax

percmin

vmax

vmin

norm_map = {'No normalization': <class 'matplotlib.colors.Normalize'>, 'log': <class 'matplotlib.colors.LogNorm'>, 'power-law': <class 'matplotlib.colors.PowerNorm'>, 'symlog': <class 'matplotlib.colors.SymLogNorm'>}
refresh_current_widget()[source]
refresh_methods(text)[source]
set_obj(obj)[source]
set_value(value)[source]
class psy_simple.widgets.colors.CMapFmtWidget(parent, fmto, project, properties=True)[source]

Bases: PyQt5.QtWidgets.QWidget

The widget for modifying the psy_simple.plotters.CMap fmt

Methods:

choose_cmap([cmap])

edit_cmap()

invert_cmap()

refresh_cb_invert(obj)

set_obj(obj)

choose_cmap(cmap=None)[source]
edit_cmap()[source]
invert_cmap()[source]
refresh_cb_invert(obj)[source]
set_obj(obj)[source]
class psy_simple.widgets.colors.CTicksFmtWidget(parent, fmto, project, properties=True)[source]

Bases: psy_simple.widgets.colors.BoundsFmtWidget

The formatoptions widget for the colorbar ticks.

Attributes:

auto_val

methods

norm_map

Classes:

methods_type

alias of psy_simple.plugin.CTicksType

Methods:

refresh_current_widget()

refresh_methods(text)

set_value(value)

auto_val = None
methods = ['Discrete', 'Auto']
methods_type

alias of psy_simple.plugin.CTicksType Attributes:

norm_map = {}
refresh_current_widget()[source]
refresh_methods(text)[source]
set_value(value)[source]
class psy_simple.widgets.colors.CmapButton(cmaps=None, current=None, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QToolButton

A button with a dropdown menu to select colormaps

Attributes:

colormap_changed(*args, **kwargs)

Methods:

open_cmap_dialog([N])

set_cmap(cmap)

setup_cmap_menu()

colormap_changed(*args, **kwargs)
open_cmap_dialog(N=10)[source]
set_cmap(cmap)[source]
setup_cmap_menu()[source]
class psy_simple.widgets.colors.ColorLabel(color='w', *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QTableWidget

A QTableWidget with one cell and no headers to just display a color

The color to display

Parameters

color (object) – Either a QtGui.QColor object or a color that can be converted to RGBA using the matplotlib.colors.to_rgba() function

Methods:

adjust_height()

Adjust the height to match the row height

select_color(*args)

Select a color using PyQt5.QtWidgets.QColorDialog.getColor()

setEnabled(self, bool)

set_color(color)

Set the color of the label

sizeHint()

Reimplemented to use the rowHeight as height

Attributes:

color

QtCore.QColor.

color_changed(*args, **kwargs)

a signal that is emitted with an rgba color if the chosen color changes

adjust_height()[source]

Adjust the height to match the row height

color = None

QtCore.QColor. The current color that is displayed

color_changed(*args, **kwargs)

a signal that is emitted with an rgba color if the chosen color changes

select_color(*args)[source]

Select a color using PyQt5.QtWidgets.QColorDialog.getColor()

setEnabled(self, bool)[source]
set_color(color)[source]

Set the color of the label

This method sets the given color as background color for the cell and emits the color_changed signal

Parameters

color (object) – Either a QtGui.QColor object or a color that can be converted to RGBA using the matplotlib.colors.to_rgba() function

sizeHint()[source]

Reimplemented to use the rowHeight as height

class psy_simple.widgets.colors.ColormapDialog(names=[], N=10, editable=True, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QDialog

A widget for selecting a colormap

Parameters
  • ``*args

    Anything else that is passed to the ColormapDialog

  • **kwargs`` – Anything else that is passed to the ColormapDialog

Methods:

get_colormap([names, N])

Open a ColormapDialog and get a colormap

show_colormap([names, N, show])

Show a colormap dialog

classmethod get_colormap(names=[], N=10, *args, **kwargs)[source]

Open a ColormapDialog and get a colormap

Parameters
  • ``*args

    Anything else that is passed to the ColormapDialog

  • **kwargs`` – Anything else that is passed to the ColormapDialog

Returns

Either the name of a standard colormap available via psy_simple.colors.get_cmap() or a colormap

Return type

str or matplotlib.colors.Colormap

classmethod show_colormap(names=[], N=10, show=True, *args, **kwargs)[source]

Show a colormap dialog

Parameters
  • *args (str or matplotlib.colors.Colormap) –

    If a colormap, it returned unchanged.

    Strings may be any valid colormap name suitable for the matplotlib.cm.get_cmap() function or one of the color lists defined in the ‘colors.cmaps’ key of the psyplot.rcParams dictionary (including their reversed color maps given via the ‘_r’ extension).

  • N (int, optional) – Default: 11. The number of increments in the colormap.

  • show (bool, optional) – Default: True. If True, show the created figure at the end with pyplot.show(block=False)

class psy_simple.widgets.colors.ColormapModel(names=[], N=10, *args, **kwargs)[source]

Bases: PyQt5.QtCore.QAbstractTableModel

A model for displaying colormaps

Parameters
  • *args (str or matplotlib.colors.Colormap) –

    If a colormap, it returned unchanged.

    Strings may be any valid colormap name suitable for the matplotlib.cm.get_cmap() function or one of the color lists defined in the ‘colors.cmaps’ key of the psyplot.rcParams dictionary (including their reversed color maps given via the ‘_r’ extension).

  • N (int, optional) – Default: 11. The number of increments in the colormap.

  • ``*args

    Anything else that is passed to the QAbstractTableModel

  • **kwargs`` – Anything else that is passed to the QAbstractTableModel

Methods:

columnCount(self[, parent])

data(index[, role])

Cell content

headerData(section, orientation[, role])

Set header data

reset()

rowCount(self[, parent])

set_colors([N, names])

columnCount(self, parent: QModelIndex = QModelIndex()) int[source]
data(index, role=0)[source]

Cell content

headerData(section, orientation, role=0)[source]

Set header data

reset()[source]
rowCount(self, parent: QModelIndex = QModelIndex()) int[source]
set_colors(N=None, names=None)[source]
class psy_simple.widgets.colors.ColormapTable(names=[], N=10, editable=True, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QTableView

A table for displaying colormaps

Parameters
  • ``*args

    Anything else that is passed to the QtWidgets.QTableView

  • **kwargs`` – Anything else that is passed to the QtWidgets.QTableView

Methods:

change_color(index)

columnCount()

rowCount()

setModel(self, QAbstractItemModel)

Attributes:

chosen_colormap

change_color(index)[source]
property chosen_colormap
columnCount()[source]
rowCount()[source]
setModel(self, QAbstractItemModel)[source]
class psy_simple.widgets.colors.DataTicksCalculatorFmtWidget(parent, method=None, methods_type=<class 'psy_simple.plugin.BoundsType'>)[source]

Bases: PyQt5.QtWidgets.QWidget

Fmt widget for psy_simple.plotters.DataTicksCalculator

This widget contains a combo box with the different options from the psy_simple.plotters.DataTicksCalculator.calc_funcs, a spin box for the number of increments and two text widgets for minimum and maximum percentile

Methods:

get_decimals(vmin, vmax)

refresh(method, fmto)

set_obj()

static get_decimals(vmin, vmax)[source]
refresh(method, fmto)[source]
set_obj()[source]
class psy_simple.widgets.colors.HighlightWidget[source]

Bases: PyQt5.QtWidgets.QWidget

Methods:

enterEvent(self, QEvent)

leaveEvent(self, QEvent)

set_highlighted(b)

enterEvent(self, QEvent)[source]
leaveEvent(self, QEvent)[source]
set_highlighted(b)[source]
class psy_simple.widgets.colors.NormalizationWidget(parent, norm)[source]

Bases: PyQt5.QtWidgets.QWidget

A simple widget representing a boundary norm

Methods:

fill_from_norm()

set_obj()

fill_from_norm()[source]
set_obj()[source]
psy_simple.widgets.colors.create_cmap_thumb(cmap, output=None)[source]