Re: Overlay TGraph and TF1?

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Mon, 5 Apr 2010 13:35:51 +0200


Hi Cedric,

see the doc: <http://root.cern.ch/root/html/TF1#TF1:Draw> By default, Draw() replaces the content of the current pad; you need to specify the option "same" for functions and histograms (but simply skip the "A" option for graphs; yes, that's inconsistent) to draw on top of existing objects.

Cheers, Axel.

On 2010-04-05 11:17, Cedric Sodhi wrote:
> Simple question: Is it possible to overlay a TGraph and a TF1 as it is
> with, say, two TGraphs or two Histograms, i.e. draw one fully and the
> other without axes?
>
> I appear not to be able to draw two of them into the same Coordsys:
>
> TGraph myg( 20 );
> for( int i = 0; i<20; i++ ) myg->SetPoint( i,i,i + rand( )%4 );
> myg.Draw( "AL" );
> TF1 myf( "myf","x+sin(x)",0,20 );
> myf.Draw( );
>
>
> In order to display a graph and a function (e.g. the expectation) in the
> same TPad, do I have to make a TGraph out of the function?
>
> Thanks!
>
>
Received on Mon Apr 05 2010 - 13:35:54 CEST

This archive was generated by hypermail 2.2.0 : Mon Apr 05 2010 - 17:50:01 CEST