/// Compilation: /// g++ -I/usr/local/share/root/root_v5_30_03/include -I ../Include -c -o test_root.o test_root_pb.cpp /// g++ test_root.o -L/usr/local/share/root/root_v5_30_03/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -lpthread -Wl,-rpath,/usr/local/share/root/root_v5_30_03/lib -lm -ldl -o test_root // The following include files contain the usual ones. #include "../Include/all_includes.h" #include "../Include/root_libs.h" // Global variable meant to be used in other functions. static TGraph grtest; int main(int argc, const char* argv[]) { using namespace std; TPostScript *myps = new TPostScript("test_root.ps",111); TCanvas c1("c1","c1",500,500); TH2D *hh = new TH2D("hres","hres",2,0,100,2,0,110); hh->SetXTitle("x"); hh->SetYTitle("y"); double x,y; int i,j,Ni=10,Nj=100; TGraph grlocal; grlocal = TGraph::TGraph(Nj+1); grtest = TGraph::TGraph(Nj+1); for(i=0;i<=Ni;++i){ for(j=0;j<=Nj;++j){ x = j; y = 2*i+j; grlocal.SetPoint(j,x,y); grtest.SetPoint(j,x,2*y); } hh->Draw(); // When the line below is commented, there is no warning message anymore. grlocal.Draw("l"); // For some reason, I have to initialize grtest at each step in a loop for(j=0;j<3;++j){ grtest = grlocal; // // ... here, call any function using grtest and potentially modifying it // grtest.SetLineColor(kRed); grtest.SetLineStyle(2); grtest.Draw("l"); c1.Update(); } } myps->Close(); delete myps; delete hh; return 0; }