Hi Jochen, You can either gROOT->SetStyle("MyStyle1"); hist->Draw(); c1_2->cd(); gROOT->SetStyle("MyStyle2"); hist->UseCurrentStyle(); hist->Draw(); or call gROOT->ForceStyle(); and next time you import your histograms from a file, the current style will be automatically applied to all the objects read from the file. Rene Brun On Thu, 12 Sep 2002, Jochen Cammin wrote: > Dear Rooters, > > I would like to change some parameters of the current style globally, e.g. > changing all fonts to Roman, without changing the font for each single > object (e.g. h->GetXaxis()->SetTitleFont(22)). Therefore I created a style > like in the attached macro. > > But I encounter some problems: > - 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,"X"); > Sty->SetLabelFont(22,"Y"); > Sty->SetOptStat(0); > Sty->SetCanvasColor(10); > Sty->SetFillColor(10); > Sty->SetTitleColor(10); > > 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:09 MET