RE: Colors writing a Canvas in a root file

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Wed, 5 Jan 2011 10:02:16 +0000


Hello,

I have just tried to reproduce your problem by:

For me it works fine, it new attributes are kept. Do you have something special in your rootlogon.C ? If you have "ForceStyle" it will overwrite the histogram attributes.

Try to start root with the option "-n". If you still get the problem send me a small running macro reproducing the problem.

Cheers,
Olivier

-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of helsens Sent: Tuesday, January 04, 2011 2:50 PM To: roottalk (Mailing list discussing all aspects of the ROOT system.) Subject: [ROOT] Colors writing a Canvas in a root file

Dear ROOTers,

I'm a bit desperate finding the solution to my problem, so I write you this mail.
What I want to do is simple I guess, but I did not succeed. I would like to keep the colors of the TH1F histos when drawing TH1F in a TCanvas.
  TFile * m_OutputFile = new TFile("ControlPlots.root","recreate");   m_OutputFile->cd();

  TH1F* tmpup = (TH1F*)nom->Clone();
  TH1F* tmpdo = (TH1F*)nom->Clone();

...//some operations
...

  TCanvas * ctmp = new TCanvas(cname,cname);   ctmp->cd();

  tmpup->SetDirectory(0);
  tmpup->SetMaximum(maxH*1.2);
  tmpup->SetMinimum(minH*1.2);
  tmpup->SetLineColor(2);
  tmpup->SetMarkerColor(2);
  tmpup->Draw("HIST");

  tmpdo->SetDirectory(0);
  tmpdo->SetLineColor(4);

  tmpdo->SetMarkerColor(4);
  tmpdo->Draw("HIST SAME");
  leg->AddEntry(tmpdo, "-1#sigma","lep");
  leg->AddEntry(tmpup, "+1#sigma","lep");
  leg->Draw();

  ctmp->Write();

then in the ControlPlots.root, the colors of the two TH1F are black... But doing
  ctmp->Print("test.png");

gives the correct colors on the .png.
Any idea how to get the colors of the TH1 in the TCanvas in the TFile?

Thanks,
Clément Received on Wed Jan 05 2011 - 11:02:21 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 05 2011 - 11:50:01 CET