#include void macro_ex() { TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); const Int_t max = 10; Double_t x[max]; Double_t y[max]; Double_t c=0; x[0]=0; y[0]=0; stringstream temp; string datetime; const char *p; gr = new TGraph(1,x, y); gr->SetMarkerStyle(21); gr->SetTitle("Time graph"); gr->GetXaxis()->SetTitle("X title"); gr->GetYaxis()->SetTitle("Y title"); c1->Update(); c1->Clear(); Int_t i =0; while(1){ t = time(0); timeinfo = localtime ( &t ); temp << timeinfo->tm_hour << ":" << timeinfo->tm_min <<":" << timeinfo-> tm_sec; datetime = temp.str(); p = datetime.c_str(); x[i] = t; if (i==max){ i=0; gr->Set(i); } if (i%2 == 0) // only to draw triangles y[i] = 2000; else y[i] = 2; gr->SetPoint(i,x[i],y[i]); gr->GetXaxis()->SetBinLabel(i,p); gr->Draw("AL"); c1->Update(); gSystem->Sleep(1000); i= i+1; } }