The zoom precision corresponds to the number of bins along x or y.
In case of log scales and a big range (in your case 1e-2 to 1e6)
the current algorithm may fail if the number of bins is too small.
I habve modified your program to be able to zoom more deeply in
your graph. see below.
Rene brun
void leggi()
{
TCanvas *c1= new TCanvas("c1","c1",200,10,700,500);
c1->SetLogy(kTRUE); c1->SetLogx(kTRUE); c1->SetGrid(kTRUE);
{ cout << "Errore apertura file!" << endl; }
char riga[10000];
float energy_,xs_,xserr_;
float energy[10000],xs[10000],xserr[10000];
while(fscanf(file,"\n%[^\n]",riga)>EOF)
{ sscanf(riga, "%f %f %f", &energy_,&xs_,&xserr_); energy[n]=energy_; xs[n]=xs_; xserr[n]=xserr_; nlines++; n++; }
TGraphErrors *gr = new TGraphErrors(nlines,energy,xs,0,xserr);
gr->SetMarkerStyle(21); gr->SetMarkerSize(0.5); gr->SetMarkerColor(4);
hpx->SetStats(kFALSE); hpx->Draw(); hpx->SetMinimum(0.01); hpx->SetMaximum(5000000); hpx->GetXaxis()->CenterTitle(); hpx->GetXaxis()->SetTitle("E_{n} (eV)"); hpx->GetYaxis()->CenterTitle(); hpx->GetYaxis()->SetTitle("#sigma (barn)");gr->Draw("lp");
On Fri,
28 Apr 2006, Marco Calviani wrote:
> Hi rooters,
> i'm trying to create a graph (with bar errors) using TGraphErrors,
> reading the data from an ASCII file. It succesfully creates the graph
> but when i try to zoom or on the X or on the Y axis, the lowest limit
> remains blocked on the minimum. How is it possible?
>
> void leggi()
> {
> TCanvas *c1= new TCanvas("c1","c1",200,10,700,500);
> int nlines=0,n=0;
> FILE *file;
> file=fopen("xs.dat","r");
> if(file==NULL)
> {
> cout << "Errore apertura file!" << endl;
> }
>
> char riga[10000];
> float energy_,xs_,xserr_;
> float energy[10000],xs[10000],xserr[10000];
> while(fscanf(file,"\n%[^\n]",riga)>EOF)
> {
> sscanf(riga, "%f %f %f", &energy_,&xs_,&xserr_);
> energy[n]=energy_;
> xs[n]=xs_;
> xserr[n]=xserr_;
> nlines++;
> n++;
> }
> fclose(file);
> cout << nlines << endl;
>
> TH2F *hpx = new TH2F("hpx","Sezione d'urto
> ^{245}Cm",nlines,0.01,5000000,1000,0.01,10000.);
> hpx->SetStats(kFALSE);
> hpx->Draw();
> hpx->GetXaxis()->CenterTitle();
> hpx->GetXaxis()->SetTitle("E_{n} (eV)");
> hpx->GetYaxis()->CenterTitle();
> hpx->GetYaxis()->SetTitle("#sigma (barn)");
> TGraphErrors *gr = new TGraphErrors(nlines,energy,xs,0,xserr);
> gPad->SetLogy(kTRUE);
> gPad->SetLogx(kTRUE);
> gPad->Modified();
> gPad->Update();
> gr->SetMarkerStyle(21);
> gr->SetMarkerSize(0.5);
> gr->SetMarkerColor(4);
> gr->Draw("LP");
> c1->SetGrid(kTRUE);
> c1->Modified();
> c1->Update();
> }
>
> Many thanks in advance,
> MC
>
Received on Sat Apr 29 2006 - 09:17:01 MEST
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET