ROOT
6.30.04
Reference Guide
All
Namespaces
Files
Pages
gtime.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphics
3
/// Example of a graph of data moving in time.
4
/// Use the canvas "File/Quit" to exit from this example
5
///
6
/// \macro_code
7
///
8
/// \author Olivier Couet
9
10
void
gtime() {
11
TCanvas *c1 =
new
TCanvas(
"c1"
);
12
const
Int_t ng = 100;
13
const
Int_t kNMAX = 10000;
14
Double_t *X =
new
Double_t[kNMAX];
15
Double_t *Y =
new
Double_t[kNMAX];
16
Int_t cursor = kNMAX;
17
TGraph *g =
new
TGraph(ng);
18
g->SetMarkerStyle(21);
19
g->SetMarkerColor(kBlue);
20
Double_t x = 0;
21
22
while
(1) {
23
c1->Clear();
24
if
(cursor > kNMAX-ng) {
25
for
(Int_t i=0;i<ng;i++) {
26
X[i] = x;
27
Y[i] = sin(x);
28
x += 0.1;
29
}
30
g->Draw(
"alp"
);
31
cursor = 0;
32
}
else
{
33
x += 0.1;
34
X[cursor+ng] = x;
35
Y[cursor+ng] = sin(x);
36
cursor++;
37
g->DrawGraph(ng,&X[cursor],&Y[cursor],
"alp"
);
38
}
39
c1->Update();
40
gSystem->ProcessEvents();
41
gSystem->Sleep(10);
42
}
43
}
44
tutorials
graphics
gtime.C
Generated on Tue May 5 2020 14:03:45 for ROOT by
1.8.5