graph.C

Go to the documentation of this file.
00001 void graph() {
00002    //Draw a simple graph
00003    // To see the output of this macro, click begin_html <a href="gif/graph.gif">here</a>. end_html
00004    //Author: Rene Brun
00005    
00006    TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
00007 
00008    c1->SetFillColor(42);
00009    c1->SetGrid();
00010 
00011    const Int_t n = 20;
00012    Double_t x[n], y[n];
00013    for (Int_t i=0;i<n;i++) {
00014      x[i] = i*0.1;
00015      y[i] = 10*sin(x[i]+0.2);
00016      printf(" i %i %f %f \n",i,x[i],y[i]);
00017    }
00018    gr = new TGraph(n,x,y);
00019    gr->SetLineColor(2);
00020    gr->SetLineWidth(4);
00021    gr->SetMarkerColor(4);
00022    gr->SetMarkerStyle(21);
00023    gr->SetTitle("a simple graph");
00024    gr->GetXaxis()->SetTitle("X title");
00025    gr->GetYaxis()->SetTitle("Y title");
00026    gr->Draw("ACP");
00027 
00028    // TCanvas::Update() draws the frame, after which one can change it
00029    c1->Update();
00030    c1->GetFrame()->SetFillColor(21);
00031    c1->GetFrame()->SetBorderSize(12);
00032    c1->Modified();
00033 }

Generated on Tue Jul 5 15:44:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1