ColormapDialog¶
A QDialog widget to set-up the colormap.
It uses a description of colormaps as dict compatible with Plot.
To run the following sample code, a QApplication must be initialized.
Create the colormap dialog and set the colormap description and data range:
>>> from silx.gui.dialog.ColormapDialog import ColormapDialog
>>> from silx.gui.colors import Colormap
>>> dialog = ColormapDialog()
>>> colormap = Colormap(name='red', normalization='log',
...                     vmin=1., vmax=2.)
>>> dialog.setColormap(colormap)
>>> colormap.setVRange(1., 100.)  # This scale the width of the plot area
>>> dialog.show()
Get the colormap description (compatible with Plot) from the dialog:
>>> cmap = dialog.getColormap()
>>> cmap.getName()
'red'
It is also possible to display an histogram of the image in the dialog. This updates the data range with the range of the bins.
>>> import numpy
>>> image = numpy.random.normal(size=512 * 512).reshape(512, -1)
>>> hist, bin_edges = numpy.histogram(image, bins=10)
>>> dialog.setHistogram(hist, bin_edges)
The updates of the colormap description are also available through the signal:
ColormapDialog.sigColormapChanged.
- 
class ColormapDialog(parent=None, title='Colormap Dialog')[source]¶
- A QDialog widget to set the colormap. - Parameters: - parent – See QDialog
- title (str) – The QDialog title
 - 
visibleChanged¶
- This event is sent when the dialog visibility change 
 - 
static computeDataRange(data)[source]¶
- Compute the data range as used by - setDataRange().- Parameters: - data – The data to process - Return type: - List[Union[None,float]] 
 - 
static computeHistogram(data, scale='linear', dataRange=None)[source]¶
- Compute the data histogram as used by - setHistogram().- Parameters: - data – The data to process
- dataRange – Optional range to compute the histogram, which is a tuple of min, max
 - Return type: - Tuple(List(float),List(float) 
 - 
setItem(item)[source]¶
- Store the plot item. - According to the state of the dialog, the item will be used to display the data range or the histogram of the data using - setDataRange()and- setHistogram()
 - 
setData(data)[source]¶
- Store the data - According to the state of the dialog, the data will be used to display the data range or the histogram of the data using - setDataRange()and- setHistogram()
 - 
setHistogram(hist=None, bin_edges=None)[source]¶
- Set the histogram to display. - This update the data range with the bounds of the bins. - Parameters: - hist – array-like of counts or None to hide histogram
- bin_edges – array-like of bins edges or None to hide histogram
 
 - 
resetColormap()[source]¶
- Reset the colormap state before modification. - ..note :: the colormap reference state is the state when set or the
- state when validated
 
 - 
setDataRange(minimum=None, positiveMin=None, maximum=None)[source]¶
- Set the range of data to use for the range of the histogram area. - Parameters: - minimum (float) – The minimum of the data
- positiveMin (float) – The positive minimum of the data
- maximum (float) – The maximum of the data
 
 - 
setColormapRangeFromDataBounds(bounds)[source]¶
- Set the range of the colormap from current item and rect. - If there is no ColormapMixIn item attached to the ColormapDialog, nothing is done. - Parameters: - bounds (Union[List[float],None]) – (xmin, xmax, ymin, ymax) Rectangular region in data space 
 - 
storeCurrentState()[source]¶
- save the current value sof the colormap if the user want to undo is modifications 
 
- parent – See 
