[ROOT] Changing styles

From: Jochen Cammin (cammin@physik.uni-bonn.de)
Date: Thu Sep 12 2002 - 12:30:18 MEST


Dear Rooters,

I would like to change some parameters of the global styles, e.g. changing 
the font to Roman on histogram labels, axis, legends etc. I know how to 
this for each object (h->GetXaxis()->SetTitleFont(22)), but I want to do 
this once at the beginning of a macro and not separately for each object. 
Therefore I created a style like in the attached macro.

But I encounter several problems:
- the font for the Yaxis is not changed
- how to change the font for the legend in the style definition?
- as described in the manual, the new style must be called before reading 
  objects from a file. Then how can I make in one macro two plots from the 
same histogram (read from a file), first with MyStyle1 and then with 
MyStyle2? The obvious way would be something like this (assume there is a 
canvas divided into two pads):

   c1_1->cd()
   gROOT->SetStyle(MyStyle1);
   hist->Draw();
   c1_2->cd();
   gROOT->SetStyle(MyStyle2);
   hist->Draw();

But as I understand from the manual this won't work.

I am using the HEAD version of root on RedHat7.2.1.

Thanks,
   Jochen

{
gROOT->Reset();

TStyle *Sty = new TStyle("MyStyle","My Style");
Sty->SetTitleFont(22);
Sty->SetLabelFont(22);
Sty->SetOptStat(0);

gROOT->SetStyle("MyStyle");


TH1F *h = new TH1F("h","A Gaussian distribution",20,-3,3);
h->FillRandom("gaus",1000);
h->GetXaxis()->SetTitle("X-Title");
h->GetYaxis()->SetTitle("Y-Title");
h->Draw();

TLegend *leg = new TLegend(0.6,0.7,0.85,0.8);
leg->AddEntry(h,"A Gaussian distribution");
leg->Draw();
}



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:11 MET