Problem with SetFillCplor for 1D histogram


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


When I execute the code snippet below, there is no fill in the histogram, even if I redraw it as done in the last line. What’s wrong?
…
Jz0C->SetStats(kFALSE);
Jz0C->Draw();
Jz0C->SetLineWidth(1);
Jz0C->SetLineColor(1);
Jz0C->SetFillColor(38);
Jz0C->SetFillStyle(3005);
Jz0C->SetMinimum(0);
Jz0C->Draw();
…

Hi,

could you provide a reproducer and the root version you are using?

Cheers,
D

Hi,

I’m running root 5.34/14 on Kubuntu 14.04. I don’t know what a reproducer is. I run the root job and the histogram is displayed, but just as a line drawing without fill.

Thanks for following up

Try (a “standalone reproducer” which works fine for me):

{
  TH1F *Jz0C = new TH1F("h_gaus", "gaus(random x, 0, 1);random x;number of enteries;", 100, -5., 5.);
  Jz0C->Sumw2(kTRUE); // an optional setting
  Jz0C->FillRandom("gaus");
  // ...
  Jz0C->SetStats(kFALSE);
  // Jz0C->Draw();
  Jz0C->SetLineWidth(1);
  Jz0C->SetLineColor(1);
  Jz0C->SetFillColor(38);
  Jz0C->SetFillStyle(3005);
  Jz0C->SetMinimum(0);
  Jz0C->Draw("HIST"); // the "HIST" is needed only if the histogram has Sumw2(kTRUE)
  // ...
  if (gPad) { gPad->Modified(); gPad->Update(); } // make sure it's really (re)drawn
}

Your code works for me too. I now recall having a problem like this before with a ROOT input file histogram. I had to explicitly transfer the contents of the input histogram to a temporary histogram before filling would work. I did that with my code and the fill works fine. There must be some feature of the input file that blocks modification. Thanks for the example and the memory jog.