Discussion:
user colormap in guiqwt
Olivier Morel
2012-08-20 11:20:07 UTC
Permalink
Dear all,

With matplotlib I create and use personnal colormaps to show images.
Nevertheless I didn't succeed in using personnal colormap with guiqwt.
Is there a way to do it ?

Thanks for your help,

Cheers

Olivier
Carlos Pascual
2012-08-20 12:41:34 UTC
Permalink
I haven't done it myself, but you probably want to use the
guiqwt.colormap.register_extra_colormap() method.

Beware of the warning about early import in said method:

def register_extra_colormap(name, colormap):
"""Add a custom colormap to the list of known colormaps
must be done early in the import process because
datasets will use get_color_map list at import time

colormap is a QwtColorMap object
"""

PD: the docs for QwtColorMap (from Qwt 5) can be found here:
http://qwt.sourcearchive.com/documentation/5.2.0-1build1/classQwtColorMap.html
Post by Olivier Morel
Dear all,
With matplotlib I create and use personnal colormaps to show images.
Nevertheless I didn't succeed in using personnal colormap with guiqwt.
Is there a way to do it ?
Thanks for your help,
Cheers
Olivier
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
Cells / Alba Synchrotron [http:/www.cells.es]
Carretera BP 1413 de Cerdanyola-Sant Cugat, Km. 3.3
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpascual-***@public.gmane.org
Phone: +34 93 592 4428
+----------------------------------------------------+
Olivier Morel
2012-08-20 13:05:11 UTC
Permalink
Thank you Carlos for your prompt reply!
It looks more complicated to me than I thought, but I will try: I
naively thought that there was a kind of bridge regarding the colormap
between matplotlib and guiqwt.

Olivier
Post by Carlos Pascual
I haven't done it myself, but you probably want to use the
guiqwt.colormap.register_extra_colormap() method.
    """Add a custom colormap to the list of known colormaps
    must be done early in the import process because
    datasets will use get_color_map list at import time
    colormap is a QwtColorMap object
    """
PD: the docs for QwtColorMap (from Qwt 5) can be found here:http://qwt.sourcearchive.com/documentation/5.2.0-1build1/classQwtColo...
Post by Olivier Morel
Dear all,
With matplotlib I create and use personnal colormaps to show images.
Nevertheless I didn't succeed in using personnal colormap with guiqwt.
Is there a way to do it ?
Thanks for your help,
Cheers
Olivier
--
+----------------------------------------------------+
 Carlos Pascual Izarra
 Scientific Software Coordinator
 Computing Division
 Cells / Alba Synchrotron  [http:/www.cells.es]
 Carretera BP 1413 de Cerdanyola-Sant Cugat, Km. 3.3
 E-08290 Cerdanyola del Valles (Barcelona), Spain
 Phone: +34 93 592 4428
+----------------------------------------------------+
Olivier Morel
2012-08-22 09:34:07 UTC
Permalink
After many tries, I've finally found a solution:
The goal was here to create a colormap with breaks as presented here
http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps
I've created the colormap and decided to use the function from guiqwt that
import matplotlib colormaps as following:

colmapQWT = QwtLinearColorMap()

_setup_colormap(colmapQWT, cdict) register_extra_colormap('toto',colmapQWT)


it works but unfortunatelly it doesn't manage breaks in the colormap...

I am not sure that QwtColorMap can manage breaks in the colormap ?


It is not so clean as with matplotlib but I did the following:

cm2 = QwtLinearColorMap(blue,green)

cm2.addColorStop(0.25, black)

cm2.addColorStop(0.5, yellow)

cm2.addColorStop(0.5, red)

cm2.addColorStop(0.75, black)

register_extra_colormap('toto3',cm2)


Olivier
Loading...