Is there a way to get the current color palette? , e.g. after `TStyle->SetPalette ( … ) `
I need to temporarily change the current pallette, and then (re)set the old palette again.
Thank you very much in advance
P.S.
from the code inspection I see that current palette index is stored in static variable `gpaletteType` in TColor.cxx. Right? But I do not see how I can access this variable. Is there a way to do it?
I’m not sure I understand where the problem is. For example, you can select the initial palette from this list. Then you can switch to another palette from the same list, and later return to the first one. It’s just a matter of storing an integer.
Perhaps you have a special case where storing the palette is more complicated. Could you provide an example that reproduces your issue?
The issue is that I have a bit complicated setup (not under my control, therefor I do not know Palette’s ID that is set). And withing this setup I’d like to call my own code/function to produce the plot, and then comeback to initial setting (that is not under my control).
As for TColor::GetColorPalette dcumentation says: “Static function returning the color number i in current palette” - that it different from what I need. (The methdo name if a bit confusing)
n [2]: ROOT.TColor.GetPalette()
Out[2]: <cppyy.gbl.TArrayI object at 0x14ae904cd438>
In [3]: ROOT.TColor.GetPalette()[0]
Out[3]: 1179
In [4]: len(ROOT.TColor.GetPalette())
Out[4]: 255
It returns all the elements of the current palette. In the general case the current palette has no id. That’s juste the current palette as defined in this example. Only the predefined palettes have number.
in other words, it is just impossible to get the index of the current (predefined) palette. Ok, I had such suspicion. It is not perfect, but it is also not a vital for me, and I can deal with it.. Thank you very much!
Yes. Indeed ROOT handles only one palette at a time. The standard way to define the palette is the link I sent you before. Now, some short cut was added for pre-defined nice palettes but at the end setting a pre-defined palette just ends up defining the palette with all its elements.