RE: Colors writing a Canvas in a root file

From: helsens <clement.helsens_at_cern.ch>
Date: Wed, 5 Jan 2011 11:17:34 +0100


Hello Olivier,

thanks a lot.
You are right, I found a gROOT->ForceStyle() in my rootlogon (to apply ATLAS Style by default).
Now this is doing the right thing.
Thanks again,
Clément

Le mercredi 05 janvier 2011 à 10:02 +0000, Olivier Couet a écrit :
> Hello,
>
> I have just tried to reproduce your problem by:
>
> - plotting an histogram,
> - changing its attributes,
> - saving it in a file,
> - exiting root,
> - and plotting the saved histogram in a new root session....
>
> 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:17:40 CET

This archive was generated by hypermail 2.2.0 : Fri Jan 07 2011 - 17:50:01 CET