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