I went over this thing again and I managed to change the gradient to the 
cubehelix colormap in this way:

I got the cubehelix RGB array 
from https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/cubehelix.py. And then these 
lines made the trick:

        hist = pyqtgraph.HistogramLUTItem()
        cubehelix = cubehelix().astype(int)
        pos, color = np.arange(0, 1, 1/256), cubehelix
        hist.gradient.setColorMap(pyqtgraph.ColorMap(pos, color))

One question remains: is there an easy way of hiding all the ticks next to 
the gradient? I don't need them and they don't look good because the 
colormap has a tick for each position between 0 and 255. I tried 
subclassing TickSliderItem but in the end I failed.



El martes, 19 de mayo de 2015, 11:37:26 (UTC-3), Federico Barabas escribió:
>
> ok, but I think that's not so easy because the cubehelix lut has a 
> continous change in color, so I can't think of a way of creating a colormap 
> with positions
>
> On Tue, May 19, 2015 at 12:00 AM, Luke Campagnola <
> [email protected]> wrote:
>
>> If you are using ImageView, then you can assign a colormap to the 
>> gradient editor rather than the image:
>>
>>     imageview.ui.histogram.gradient.setColorMap(colormap)
>>
>> This should also make it unnecessary to deal with the widget resize 
>> resetting the LUT. 
>>
>> On Sun, May 17, 2015 at 1:04 PM, Federico Barabas <[email protected]
>> > wrote:
>>
>>> The only (small) thing that bugs me is the fact that the gradient in the 
>>> HistogramLutItem doesn't reflect the cubehelix gradient
>>>
>>> On Sun, May 17, 2015 at 1:54 PM, Federico Barabas <
>>> [email protected]> wrote:
>>>
>>>> Awesome!
>>>> I didn't want to use an ImageView, so in the update routine I did this:
>>>>
>>>> self.img.setImage(image, autoLevels=False, lut=self.lut)
>>>>
>>>>
>>>> where self.lut points to the cubehelix
>>>>
>>>> On Fri, May 15, 2015 at 4:33 PM, dyadkin <[email protected]> wrote:
>>>>
>>>>> Finally, I have written a generator of lookup table for pyqtgraph.
>>>>> Cubehelix:
>>>>>
>>>>> def cubehelix(gamma=1.0, s=0.5, r=-1.5, h=1.0):
>>>>>     def get_color_function(p0, p1):
>>>>>         def color(x):
>>>>>             xg = x ** gamma
>>>>>             a = h * xg * (1 - xg) / 2
>>>>>             phi = 2 * np.pi * (s / 3 + r * x)
>>>>>             return xg + a * (p0 * np.cos(phi) + p1 * np.sin(phi))
>>>>>         return color
>>>>>
>>>>>     array = np.empty((256, 3))
>>>>>     abytes = np.arange(0, 1, 1/256.)
>>>>>     array[:, 0] = get_color_function(-0.14861, 1.78277)(abytes) * 255
>>>>>     array[:, 1] = get_color_function(-0.29227, -0.90649)(abytes) * 255
>>>>>     array[:, 2] = get_color_function(1.97294, 0.0)(abytes) * 255
>>>>>     return array
>>>>>
>>>>>
>>>>> Rainbow:
>>>>>
>>>>>
>>>>> def rainbow():
>>>>>     array = np.empty((256, 3))
>>>>>     abytes = np.arange(0, 1, 0.00390625)
>>>>>     array[:, 0] = np.abs(2 * abytes - 0.5) * 255
>>>>>     array[:, 1] = np.sin(abytes * np.pi) * 255
>>>>>     array[:, 2] = np.cos(abytes * np.pi / 2) * 255
>>>>>     return array
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to a topic in the 
>>>>> Google Groups "pyqtgraph" group.
>>>>> To unsubscribe from this topic, visit 
>>>>> https://groups.google.com/d/topic/pyqtgraph/gEjC08Vb8NQ/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to 
>>>>> [email protected].
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/pyqtgraph/e4383d01-410b-422a-a472-2fa0388342b8%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/pyqtgraph/e4383d01-410b-422a-a472-2fa0388342b8%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "pyqtgraph" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pyqtgraph/CAFGKJ92gPN4-%2Br11HvDx6TUnPJyv7tg5kRFWFUi3nat4KkK-9Q%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/pyqtgraph/CAFGKJ92gPN4-%2Br11HvDx6TUnPJyv7tg5kRFWFUi3nat4KkK-9Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "pyqtgraph" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/pyqtgraph/gEjC08Vb8NQ/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pyqtgraph/CACZXET8Z6wKKOvH_Q6CTV2yZzss0%3DLMfcSxQQprL%2BVR2-M%2BujA%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/pyqtgraph/CACZXET8Z6wKKOvH_Q6CTV2yZzss0%3DLMfcSxQQprL%2BVR2-M%2BujA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/2731064b-1faf-4fc4-a189-0c0623eb24c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to