Hi,

You can set your own custom tick colors and positions on a colormap bar 
with something like this:

cbar = pg.HistogramLUTItem(image=some_image)
cbar.gradient.restoreState({"mode": "rgb", "ticks":
    [(0.0, (0.374272, 0.119296, 3.549696)),
    (0.125, (28.952064, 16.765952, 70.856704)),
    (0.25, (81.063424, 18.35264, 124.25728)),
    (0.375, (131.284736, 37.933824, 129.957888)),
    (0.5, (183.395072, 55.035392, 121.67424)),
    (0.625, (231.495936, 81.82016, 99.363072)),
    (0.75, (252.5952, 137.108992, 97.84576)),
    (0.875, (255.205888, 197.015296, 136.932352))]})

Those tick positions should be a decent copy of magma, which I created with

from matplotlib import cm
ticks = [(i/256, tuple([256*j for j in cm.magma.colors[i]])) for i in range(
0, cm.magma.N, 32)]

Patrick

On Thursday, 12 September 2019 00:39:59 UTC+9:30, Gene Beidl wrote:
>
> I am creating a spectrogram to be displayed as an image and I want to use 
> the magma colormap from Matplotlib.
>
> It's shown here:
> https://matplotlib.org/users/colormaps.html
>
> And some 'magma' mapped spectrograms are here:
> https://librosa.github.io/librosa_gallery/auto_examples/plot_hprss.html
>
> Is there a way to use Matplotlib colormaps with an image in pyqtgraph?
>
> Thanks!
>
>
>

-- 
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/98e87169-553c-466d-967c-4892d84c8245%40googlegroups.com.

Reply via email to