Defining my own palette in pyroot

Hello

I have a palette (I defined on my own) on C++ code. I would like to use it also in pyroot.

I know how to set a new pyroot palette, my problem is more how to get the array of colors of my C++ palette to feed the pyroot palette.

myPalette = numpy.array([0, 1, 2, 3, 4, 5, 6, 7], dtype=numpy.int32)
gStyle.SetPalette (8,myPalette)

So… how can I extract the array of colors of my C++ palette created with TColor::CreateGradientColorTable(num, stops, red, green, blue, …)

Thanks
Salva


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi @martis,

As per the documentation of TColor::CreateGradientColorTable(), the function returns the index of the first color in the palette.
Thus, let begin be the return value of CreateGradientColorTable(), then palette indices lie on the interval [begin, begin + NColors), i.e. in Python

myPalette = numpy.array(range(begin, begin + NColors), dtype=numpy.int32)

Cheers,
J.