Dear Rooters,
I'm trying to plot a set of data to which new points are continuously being
added. To test this out, I wrote the following macro, which calculates the
difference between two values and then plots the difference. I included a
loop that increases the number of points to graph with each iteration, and
redraw the graph with every iteration. The graph works as I had hoped,
clearing the active pad and redrawing the graph each time a new data point
is added. However, I can't seem to get the axes to redraw, and this results
in a bunch of different overlapping scales on both the x- and y-axis. Any
suggestions?
Thanks,
Jason
void Dynamic()
{
Int_t i;
const Int_t N = 32;
Double_t x[N+1] =
{ 293., 291., 288., 286., 280., 270., 260., 250.,
240., 230., 220., 210., 200., 190., 180., 170.,
160., 150., 140., 130., 120., 110., 100., 90.,
80., 70., 60., 50., 40., 30., 20., 10., 0.
};
Double_t y[N+1] =
{
52.1705, 81.5672, 0.0, 37.2873, 118.617, 203.3, 270.579, 349.675, 430.074,
511.98, 593.394, 667.308, 753.741, 828.314, 906.517, 984.533, 1065.13,
1144.57, 1221.71, 1300.72, 1385.65, 1467.83, 1552.11, 1633.02, 1711.6,
1796.59, 1881.22, 1967.85, 2051.02, 2135.62, 2221.47, 2311.31, 2400.0
};
Double_t dy[N] = {0.};
for (i=N-1; i>0; i--) dy[i] = y[i+1] - y[i];
TCanvas *c1 = new TCanvas("c1","Voltage Differences",1);
for (i = 1; (i < N); i++)
{
TGraph *gr1 = new TGraph(i);
gr1->SetMarkerStyle(7);
gr1->SetMarkerColor(4);
gr1->SetMarkerSize(2);
gr1->SetLineColor(4);
gr1->DrawGraph(i, x, dy, "ALP");
gPad->Update();
delete gr1;
}
}
p.s, I'm using version 3.05/05.
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET