this is my program after your suggestions: // corrected macro { TGraph *g=new TGraph(10); for (int i=0 ; i<10 ; i++) {g->SetPoint(i,i,i);} g -> SetMarkerStyle(20); TCanvas *c = new TCanvas("c","c"); // TH1F *hframe = new TH1F ("hframe","",10,1,10); // hframe -> SetMinimum(0); // hframe -> SetMaximum(10); // hframe -> SetStats(0); // g->SetHistogram(hframe);*/ g->SetMinimum(0); // ------- correcetd g->SetMaximum(10); // ---- corrected g -> Draw("ap"); c -> Modified(); } I saved this canvas into c1.c (see attachment) which contains: ... TH1 *Graph1 = new TH1F("Graph1","Graph",100,0,9.9); Graph1->SetMinimum(0); Graph1->SetMaximum(10); Graph1->SetDirectory(0); Graph1->SetStats(0); graph->SetHistogram(Graph1); ... what is the same approach as I used in my original program. if I now call .x c1.c, the zoom problem arises. so why does root save macros in shown way (c1.c) when you suggest to use "corrected macro"? ivan Ivan, I cannot reproduce this problem. Could you be more explicit? I also suggest to use the PRO version 3.03/09 Rene Brun On Wed, 23 Oct 2002, ivan brida wrote: > hi Rene > > I corrected my program according to your suggestion and it works fine. > but if I save the canvas c (created with corrected program) into e.g. > c.c, this file contains similar lines as my original program and the > same approach via TH1F. and if I call this macro via .x c.c, the > original problem vith zooming y-axis arises. so the question is why does > root save canvases in such a way? > > ivan > > Hi Ivan, > > Replace the following lines in your program: > TH1F *hframe = new TH1F ("hframe","",10,1,10); > hframe -> SetMinimum(0); > hframe -> SetMaximum(10); > hframe -> SetStats(0); > g->SetHistogram(hframe); > by > g->SetMinimum(0); > g->SetMaximum(10); > > Rene Brun > > On Wed, 23 Oct 2002, ivan brida wrote: > > > hi rooters > > > > I have problem with zooming the y-axis. I do this: > > > > { TGraph *g=new TGraph(10); > > for (int i=0 ; i<10 ; i++) {g->SetPoint(i,i,i);} > > g -> SetMarkerStyle(20); > > TCanvas *c = new TCanvas("c","c"); > > TH1F *hframe = new TH1F ("hframe","",10,1,10); > > hframe -> SetMinimum(0); > > hframe -> SetMaximum(10); > > hframe -> SetStats(0); > > g->SetHistogram(hframe); > > g -> Draw("ap"); > > c -> Modified(); > > } > > > > the y-maximum is 10. if I zoom the y-axis interactively (e.g. y=2..5) > > and then unzoom, the hframe->GetMaximum() returns the value 1. > > this problem doesn't occur for x-axis. > > > > I use root version 3.03/08 20.8.2002, win 2000. > > > > could anybody help me? > > > > thanks > > > > ivan > > > > -- _____________________________ Ivan Brida Department of Nuclear Physics Faculty of mathematics, physics and informatics Comenius University Mlynska Dolina 84248 Bratislava Slovak Republic brida@fmph.uniba.sk { //=========Macro generated from canvas: c/c //========= (Wed Oct 23 18:38:54 2002) by ROOT version3.03/08 TCanvas *c = new TCanvas("c", "c",0,0,685,440); c->Range(-1.19741,-1.1745,11.1829,11.3087); c->SetBorderSize(2); c->SetFrameFillColor(0); TGraph *graph = new TGraph(10); graph->SetName("Graph"); graph->SetTitle("Graph"); graph->SetFillColor(1); graph->SetMarkerStyle(20); graph->SetPoint(0,0,0); graph->SetPoint(1,1,1); graph->SetPoint(2,2,2); graph->SetPoint(3,3,3); graph->SetPoint(4,4,4); graph->SetPoint(5,5,5); graph->SetPoint(6,6,6); graph->SetPoint(7,7,7); graph->SetPoint(8,8,8); graph->SetPoint(9,9,9); TH1 *Graph1 = new TH1F("Graph1","Graph",100,0,9.9); Graph1->SetMinimum(0); Graph1->SetMaximum(10); Graph1->SetDirectory(0); Graph1->SetStats(0); graph->SetHistogram(Graph1); graph->Draw("ap"); TPaveText *pt = new TPaveText(0.01,0.945,0.118083,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(2); pt->SetFillColor(19); TText *text = pt->AddText("Graph"); pt->Draw(); c->Modified(); c->cd(); }
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:15 MET