Re: How can I superimpose several graphs on top of existing graph?

From: Chris Jillings (chris@sno.phy.queensu.ca)
Date: Tue Mar 10 1998 - 17:40:12 MET


Jayoung,
    I had the same problem, so if I may be so  forward as to answer...

TGraph, and TGraphErrors do not take the "SAME" argument in their Draw
functions. To overlay, simply drop the "A" from the draw argument.
In your code sample, I have put in the modified line.

    See tutorial 18 in the web pages for more details.

Chris

On Tue, 10 Mar 1998, Jayoung Wu wrote:

> 
> Hi,
> I would like to plot two graphs on a plot using "TGraph". How I can do it?
> ========================== part of my code ====================
> ...
> 
> TGraph *gr0 = new TGraph(pnoy,iypos,pzzy);
> TGraph *gr = new TGraph(pnoy,pypos,pzzy);
> 
>     pad0->Draw();
>     pad0->cd();
>     Float_t xr[2] = {-23.0,23.0};
>     Float_t yr[2] = {-25,48.25};
>     Int_t nch = 2;
>     gr0->PaintGraph(nch,xr,yr,"AP");
>     gr0->Draw("AL*");
> 
>     gr->SetMarkerColor(4);
>     gr->SetMarkerStyle(21);
>     gr->Draw("Same");

Try 

      gr->Draw("L");  // for example a line graph on the same plot.
                      // Do not put the A in.

> 
>     pad0->Modified();
> ================================================================
> When I execute the macro, it plot only "gr0" not "gr" without any warning
> or error message. Do you have any idea?
> TF1 seems to be able to superimpose a plot on top of existing picture.
> Is TGraph able to do it?
> 
> ---
> Thanks a lot!
> Jayoung
>  
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:30 MET