Re: [ROOT] How to setting Y axis on a TGraph picture with slider

From: Yongzhao Zhou (Yongzhao.Zhou@lnf.infn.it)
Date: Wed Jun 21 2000 - 17:11:25 MEST


Dear Prof. Rene Brun,
Thank you for your help.
I tried your example and got a TGraph picture with two sliders. The
sliders can be work very well but the Y scaler can not be changed by left  
button of the mouse on the context menu to select SetMaximum.
Is it true that function changing Y scaler can not work together with
slider on a picture of TGraph or TH1?
Best Regards,
Yongzhao Zhou 


------
Yongzhao Zhou, KLOE, LNF, INFN, Italy
Tel:39-06-94032696 Fax:39-06-94032427


On Wed, 21 Jun 2000, Rene Brun wrote:

> Yongzhao Zhou wrote:
> > 
> > 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
> > 
> > ------
> 
> Here is an example with sliders and a TGraph
> do
>  root > .x gslider.C
> 
> //------------macro gslider.C
> {
>    //Example of macro with two sliders
> 
>    TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
>    c1->SetFillColor(38);
> 
>    TPad *pad = new TPad("pad","lego pad",0.1,0.1,0.98,0.98);
>    pad->SetFillColor(33);
>    pad->Draw();
>    pad->cd();
> //   gStyle->SetFrameFillColor(42);
>    pad->SetFillColor(42);
>    pad->SetGrid();
>    pad->DrawFrame(0,0,2,11);
> 
>    const Int_t n = 20;
>    Double_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);
>    }
>    gr = new TGraph(n,x,y);
>    gr->SetLineColor(2);
>    gr->SetLineWidth(4);
>    gr->SetMarkerColor(4);
>    gr->SetMarkerStyle(21);
>    gr->SetTitle("a simple graph");
>    gr->Draw("CP");
> 
>    
>    //Create two sliders in main canvas. When button1 will be released
>    //the macro xysliderAction.C will be called.
>    c1->cd();
>    TSlider *xslider = new TSlider("xslider","x",0.1,0.02,0.98,0.08);
>    xslider->SetMethod(".x gsliderAction.C");
>    TSlider *yslider = new TSlider("yslider","y",0.02,0.1,0.06,0.98);
>    yslider->SetMethod(".x gsliderAction.C");
> }
> 
> //-----------------macro gsliderAction.C
> {
>    Float_t xrange = 2;
>    Float_t yrange = 11;
>    Float_t xmin = xrange*xslider->GetMinimum();
>    Float_t xmax = xrange*xslider->GetMaximum();
>    Float_t ymin = yrange*yslider->GetMinimum();
>    Float_t ymax = yrange*yslider->GetMaximum();
>    pad->cd();
>    pad->DrawFrame(xmin,ymin,xmax,ymax);
>    gr->Draw("cp");
>    c1->Update();
> }
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:28 MET