TGraph slider question

Eddy Offermann (eddy@rentec.com)
Thu, 1 Oct 98 21:47:04 EDT


Hi Rooters,

I still did not figure out how to get the slider in the DrawPanel
working for a TGraph.

Rene Brun wrote:

> The TGraph::DrawPanel function is currently not implemented.
> I have added a message in the new version.
> Currently there are two ways to zoom on a graph:
> - via the command line by changing the pad range
> - drawing a TH1F empty object (setting min and max), then
> drawing the graph on top and invoking DrawPanel on the TH1F object.

I like the second option because it seems only a few mouse clicks away.
So I tried the following macro:

{
gROOT->Reset();
c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);

Int_t n = 10;
Float_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i*0.1;
y[i] = x[i];
}

hpx = new TH1F("hpx","This is the px distribution",10,0,1);
hpx->SetMinimum(0.0);
hpx->SetMaximum(1.0);
hpx->SetXTitle("X title");
hpx->SetYTitle("Y title");
hpx->Draw();

gr = new TGraph(n,x,y);
gr->SetLineColor(2);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(21);
gr->Draw("CP");
}

The DrawPanel works for 'hpx' but I lose the data points of the graph because
they do not get updated. Is there a statement, I should add ??

Best Regards,
Eddy Offermann