Dear Prof. Rene Brun, Sure, I can change Y scale on a canvas with TGraph by left button of the mouse using option "ALP" or "AL" to draw a TGraph but in that case the slider will not be worked. Is there any function directly to change X scaler of TGraph as action of TH1 in the macro grSliderAction.C of my code? Because I did not find a function directly to change the X scaler of a TGraph so I have to use a TH1 plot and draw a TGraph picture on it to make slider working on TGraph picture. Best Regards, Yongzhao Zhou ------ Yongzhao Zhou, KLOE, LNF, INFN, Italy Tel:39-06-94032696 Fax:39-06-94032427 On Tue, 20 Jun 2000, Rene Brun wrote: > Hi Yongzhao, > > You can change the vertical scale (min/max) on a canvas with TH1 > or TGraph directly using the left button of your mouse. > > Calling TGraph::SetMaximum via the context menu may not work if you > use the option "AL" to draw the graph. The option "A" forces a > recomputation of the min/max of the TGraph. > > Rene Brun > > Yongzhao Zhou wrote: > > > > Dear Rooters, > > A macro based slider example on root v2.23 is > > > > //=============macro slider.C============================= > > { > > gROOT->Reset(); > > > > // --- setting canvas and pad > > c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); > > > > c1->SetFillColor(42); > > c1->SetGridx(); > > c1->SetGridy(); > > pad1 = new TPad("pad1","c1",0.1,0.1,0.9,0.9,18); > > > > pad1->SetGrid(); > > pad1->SetBottomMargin(0.3); > > pad1->SetLeftMargin(.3); > > pad1->SetRightMargin(.3); > > pad1->Draw(); > > > > // --- Draw a histogram plot > > pad1->cd(); > > > > Int_t n = 20; > > Float_t x[n], y[n]; > > for (Int_t i=0;i<n;i++) { > > x[i] = i*0.1; > > y[i] = 10*sin(x[i]+0.2); > > } > > Float_t xmin = 0; > > Float_t xmax = 2; > > Float_t ymax = 11; > > TH1F *hist = new TH1F("hist","a simple graph",100,xmin,xmax); > > hist->SetMaximum(15); > > hist->SetMinimum(-2); > > hist->Draw(); > > hist->SetXTitle("X title"); > > hist->SetYTitle("Y title"); > > > > // --- Draw a graph > > gr = new TGraph(n,x,y); > > gr->SetFillColor(1); > > gr->SetLineColor(2); > > gr->SetLineWidth(4); > > gr->SetMarkerColor(4); > > gr->SetMarkerStyle(21); > > gr->SetTitle("a simple graph"); > > gr->Draw("LP"); > > > > // --- Create one slider in main canvas > > pad1->Update(); > > c1->Update(); > > TSlider *xslider = new > > TSlider("xslider","x",xmin,ymax,xmax,ymax+1.7); > > xslider->SetMethod(".x grSliderAction.C"); > > } > > > > /* > > // --- This macro is another C codes > > //===========macro grSliderAction.C============== > > { > > Int_t nx = hist->GetXaxis()->GetNbins(); > > Int_t binxmin = nx*xslider->GetMinimum(); > > Int_t binxmax = nx*xslider->GetMaximum(); > > hist->GetXaxis()->SetRange(binxmin,binxmax); > > > > c1->Modified(); > > c1->Update(); > > } > > */ > > > > But the function SetMaximum on a pop-up menu by clicking with the righ > > moose button on the TGraph picture can not set and change the Y axis. > > I don't know why. > > Thanks for any help. > > Best Regards, > > Yongzhao Zhou > > > > ------ > > Yongzhao Zhou, KLOE, LNF, INFN, Italy > > Tel:39-06-94032696 Fax:39-06-94032427 >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:28 MET