Get list of colors (contour like array)

Hi! I have to draw a number of TH1s in the same pad and i would like to set the color somehow automatically…
for TH2 there is the mechanics of SetContour that takes an array of numerical limits the automatically color the areas.
Could be possible to have something like
Color_t* GetColorArray( Int_t nlevels, const Double_t * levels = 0) that would return an array of Color_t (shorts) where the output elements is an color array mapped to the levels elements?

Thank you!
Adrian

Hi Adrian,
let’s ping @couet and @bellenot, maybe they can help

Hi,

Did you look at the Color palettes chapter of the TColor class reference?
And especially TColor::CreateGradientColorTable

Cheers, Bertrand.

Hi! No, i was not aware of this … very nice … i was looking over the class reference and while example is clear for a TF2 (or any T*2 that have SetContour) it is not clear to my how can i extract ordered colors from the gradient in order to have something like
h1->SetMarkerColor(color_array[0]);


h5->SetMarkerColor(color_array[4]);

i also discovered ->Draw(“SAME PLC PMC”);
which is very nice but it not controllable (or i did not found out how to do it …)

Thank you!!!
Adrian

So what you want to do is to define a color map and pick a color in it according to a value range mapped on this color map ? … what the option COL does for you in fact …

no, not exactly … so :

  1. i am talking about TH_1_
  2. about the color of line and markers
  3. the range i am referring to is a range of colors

if i have 10 histogram on the pad i would like (maybe useful to others)
to have a color range (lets say 10 colors) and have something like

h1->SetMarkerColor(color_array[0]);



h10->SetMarkerColor(color_array[9]);

the problem is that there is no exposed mechanics for getting a color
range (something like : this is the palette, split in 10, get me the
color at index Idx)

I apologize if i fail to make myself understood (again) :slight_smile:

Thank you!!
Adrian

I can see two way of doing it:

  1. as you describes it yourself i.e.: define an array containing 10 colors and select them as you wish
  2. define a palette with 10 colors and use the new options PLC PMC

I can see two way of doing it:

  1. as you describes it yourself i.e.: define an array containing 10 colors and select them as you wish
    well, it is not so automatic …
  1. define a palette with 10 colors and use the new options PLC PMC
    well, i did not think about this …
    i see this :
    ROOT: TColor Class Reference

but the array must be populated by hand …
is there a way to say :
starting from red to blue populate an array[10] with 10 equidistant
colors ?

Thank you!
Adrian

Yes you can define your own palette as shown here: ROOT: TColor Class Reference

2nd example …

ups, sorry about that! brain took a pause :frowning:

Thanks a lot!!
Adrian

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.