RE: help axis

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 13 Mar 2008 17:39:06 +0100


Hi Luca,

You should do:

{
  TFile *f=TFile::Open("hsimple.root");
  TTree *ntuple = (TTree*)f->Get("ntuple");   TCanvas *c1 = new TCanvas();
  c1->SetLogy();
  ntuple->Draw("pz:px>>h2(50,-3,3,50,1e-2,20)","","");

  TH2 *h2 = (TH2*)gDirectory->Get("h2");

  TGraph *graph = (TGraph*)gPad->GetPrimitive("Graph");   graph->GetYaxis()->SetTitle("Y title");   graph->GetXaxis()->SetTitle("X title");   TCanvas *c2 = new TCanvas();

  graph->Draw("ap");
  graph->GetXaxis()->SetLimits(-3.,3.);
  graph->GetHistogram()->SetMinimum(0.01);
  graph->GetHistogram()->SetMaximum(20);
  c2->SetLogy();

  h2->SetMaximum(0);
  h2->Draw("sames");
}

-----Original Message-----
From: Luca Grandi [mailto:luca.grandi_at_pv.infn.it] Sent: Thursday, March 13, 2008 3:19 PM
To: Olivier Couet
Subject: Re: [ROOT] help axis

Thanks Olivier,

but in this way I am not able to decide the limit on the x axis. I have tried using graph->SetUserRange but with no luck.

Luca

On 12-mar-08, at 18:53, Olivier Couet wrote:

> I found a solution but it is not very nice...
>
> {
> TFile *f=TFile::Open("hsimple.root");
> TTree *ntuple = (TTree*)f->Get("ntuple");
> TCanvas *c1 = new TCanvas();
> c1->SetLogy();
> ntuple->Draw("pz:px>>h2(50,-3,3,50,1e-2,20)","","");
>
> TH2 *h2 = (TH2*)gDirectory->Get("h2");
>
> TGraph *graph = (TGraph*)gPad->GetPrimitive("Graph");
> graph->GetYaxis()->SetTitle("Y title");
> graph->GetXaxis()->SetTitle("X title");
> TCanvas *c2 = new TCanvas();
> graph->Draw("ap");
> c2->SetLogy();
> h2->SetMaximum(0);
> h2->Draw("sames");
> }
>
> -----Original Message-----
> From: owner-roottalk_at_root.cern.ch [mailto:owner-
> roottalk_at_root.cern.ch] On Behalf Of Luca Grandi
> Sent: Wednesday, March 12, 2008 6:00 PM
> To: roottalk (Mailing list discussing all aspects of the ROOT system)
> Subject: [ROOT] help axis
>
> Dear Rooties,
>
> I am using the code below to plot a scatter plot on semi-logarithmic
> scale
> and, at the same time, to be able to plot the Stats.
>
> I have tried different solutions but I am unable to write the title
> on the
> axis of the scatter plot.
>
> Could you help me?
>
> Thanks
>
> Luca
>
>
>
> {
>
> TFile *f=TFile::Open("hsimple.root");
>
> TTree *ntuple = (TTree*)f->Get("ntuple");
>
> TCanvas *c1 = new TCanvas();
>
> c1->SetLogy();
>
> ntuple->Draw("pz:px>>h2(50,-3,3,50,1e-2,20)","","");
>
> TH2 *h2 = (TH2*)gDirectory->Get("h2");
>
> h2->SetMaximum(0);
> h2->Draw("sames");
> }
>
>
Received on Thu Mar 13 2008 - 17:39:16 CET

This archive was generated by hypermail 2.2.0 : Thu Mar 13 2008 - 23:50:01 CET