Thomas, In attachement, you will find an example of a transparent pad. This example is now in CVS in the tutorials directory. Rene Brun Thomas Bretz wrote: > > Hi Rene, > > I don't want to copy the histogramm... Where can I find information > about 'transparent pads'? > > Thomas. > > Rene Brun wrote: > > Hi Thomas, > > > > Use DrawCopy or transparent pads > > > > Rene Brun > > > > On Mon, 13 Sep 2004, Thomas Bretz wrote: > > > > > >>Hi, > >> > >>I had a look at > >>http://root.cern.ch/root/html/examples/twoscales.C.html > >> > >>but this solution has a problem. I'm superimposing two histograms, but > >>therefor I have to change the units of one of the histograms (Scale()). > >>But I still want to use the histogram afterwards. > >> > >>The problem is, that my program looks like this: > >>0) Fill Data into histograms > >>1) Draw histogram1 > >>2) Superimpose histogram2 > >>3) Do something with the histogram... > >>4) goto 0) > >> > >>But this doen't easily allow changing the scale of the histogram. > >>Another solution would be to draw a copy of the contents of the > >>histogram, but this takes a lot of time which I don't have... > >> > >>Is ther e any other solution? > >> > >>Thomas. > >> > > > > // Example of a canvas showing two histograms with different scales. // The second histogram is drawn in a transparent pad void transpad() { TCanvas *c1 = new TCanvas("c1","transparent pad",200,10,700,500); TPad *pad1 = new TPad("pad1","",0,0,1,1); TPad *pad2 = new TPad("pad2","",0,0,1,1); pad2->SetFillStyle(4000); //will be transparent pad1->Draw(); pad1->cd(); TH1F *h1 = new TH1F("h1","h1",100,-3,3); TH1F *h2 = new TH1F("h2","h2",100,-3,3); TRandom r; for (Int_t i=0;i<100000;i++) { Double_t x1 = r.Gaus(-1,0.5); Double_t x2 = r.Gaus(1,1.5); if (i <1000) h1->Fill(x1); h2->Fill(x2); } h1->Draw(); pad1->Update(); //this will force the generation of the "stats" box TPaveStats *ps1 = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats"); ps1->SetX1NDC(0.4); ps1->SetX2NDC(0.6); pad1->Modified(); c1->cd(); //compute the pad range with suitable margins Double_t ymin = 0; Double_t ymax = 2000; Double_t dy = (ymax-ymin)/0.8; //10 per cent margins top and bottom Double_t xmin = -3; Double_t xmax = 3; Double_t dx = (xmax-xmin)/0.8; //10 per cent margins left and right pad2->Range(xmin-0.1*dx,ymin-0.1*dy,xmax+0.1*dx,ymax+0.1*dy); pad2->Draw(); pad2->cd(); h2->SetLineColor(kRed); h2->Draw("sames"); pad2->Update(); TPaveStats *ps2 = (TPaveStats*)h2->GetListOfFunctions()->FindObject("stats"); ps2->SetX1NDC(0.65); ps2->SetX2NDC(0.85); ps2->SetTextColor(kRed); // draw axis on the right side of the pad TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,ymin,ymax,50510,"+L"); axis->SetLabelColor(kRed); axis->Draw(); }
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET