Re: plotting two TGraphs

Rene Brun (Rene.Brun@cern.ch)
Wed, 11 Feb 1998 15:08:36 +0100


Wouter Hulsbergen wrote:
>
> Dear Root editors,
> I have two data sets which I would like to plot together. Is it possible
> to draw two TGraphs in the same plot ?
> Regards, Wouter

Here is a macro illustrating how to draw two graphs in the same pad.

Rene Brun

{
gROOT->Reset();
c1 = new TCanvas("c1");
c1->SetGrid();
c1->DrawFrame(0,0,2000,70);

Float_t x[] = {400,700,900,1100,1800};
Float_t y[] = {12,7,10,20,60};
Float_t u[] = {300,700,900,1100,1900};
Float_t v[] = {2,4,20,40,60};

gr1 = new TGraph(5,x,y);
gr1->SetMarkerStyle(21);
gr1->Draw("lp");

gr2 = new TGraph(5,u,v);
gr2->SetMarkerStyle(22);
gr2->Draw("lp");
}