Setting histogram markers, colours etc gets mixed up

Dear ROOT experts,

I have a python script that plots my histograms.

I have once in a while encountered the situation that I want to set histograms markers colours, type, lines, etc etc, and that the result is not the one I intend. For example, one histogram gets the colour of the next or the previous histogram

I plot many histograms in the same plot, and I do for instance:

  rrcolor=kOrange+7
   h_estrr.SetLineColor(rrcolor);
   h_estrr.SetLineWidth(3)
  
   rfcolor=kGreen
   h_estrf.SetLineColor(rfcolor)   
   h_estrf.SetLineWidth(3)
      
   ffcolor=kRed+1
   h_estrf.SetLineColor(ffcolor)
   h_estff.SetLineWidth(3)
   
   hframe = h['mc'].Clone()
   hframe.Reset();
   hframe.SetMaximum(YMax)
   hframe.Draw()

  # already set the style earlier
   h['data'].Draw("pe same")
   tleg.AddEntry(h['data'],"Data 2011 #sqrt{s} = 7 TeV","pl")
   
  h_estrr.Draw("same")
   tleg.AddEntry(h_estrr,"Est rr")

   h_estrf.Draw("same")
   tleg.AddEntry(h_estrf,"Est rf")

   h_estff.Draw("same")
   tleg.AddEntry(h_estff,"Est ff")

this results in the plot attached. You see that the histogram called “rf” should according to my code be coloured kGreen, while in the plot you see it has the colour kRed+1 - which is the colour my histogram “ff” is supposed to have. Then my “ff” histogram has the colour black (which is the colour of my datapoints)

This problem also shows up with markers, where my points can “inherit” or “use” the marker of another histogram, and not the one I coded.

What am I doing wrong? Have you seen this “feature” before?

Thanks,
Maiken


Maiken,

looks to me that there’s a simple naming error:

[code] h_estrf.SetLineColor(rfcolor)
h_estrf.SetLineWidth(3)

ffcolor=kRed+1
h_estrf.SetLineColor(ffcolor)
h_estff.SetLineWidth(3)[/code]
in that you set the line color on h_estrf instead of h_estff. As a general rule, the human mind triggers best on the first and last character of a word, so only changing the inner portions of a variable name by one character is not recommended. :slight_smile:

Cheers,
Wim

Wow, that was an easy one. I have encountered this several times, but of course it can be that I each time manage to introduce some naming error!

Thank you very much, and sorry for wasting your time!!
Maiken