TGraph plotting several graphs


I often encounter a situation when I have to plot several graphs on top of each other, and often if the “Y” ranges of the graphs are way off, of course you lose the second graph drawn on top of the graph with axis drawn.

I was wondering if there is an elegant way to be able to draw several graphs and have ROOT readjust the “Y”-axis scale to make all of them visible ?


see class TMultiGraph and numerous examples like $ROOTSYS/tutorials/graphs/multigraph.C


Thanks Rene for the examples, somehow I missed them,
But now have a further concern with this class, it does not seem to allow passing different options to different graphs.
Say I add two graphs into it, and I want to plot one with points and another with line (theory vs experiment so to speak), is there a way to do that ?

pass the option when adding tge TGraph to the TMultiGraph, eg

TGraph *g1, *g2 multi->Add(g1,"l"); multi->Add(g2,"p");
see doc of TMultiGraph::Add


That worked, with a little strange behavior though. When I do

TGraphErrors *g1, *g2

for graph g1 it draws the line but also draws the error bars, but no points.
But I guess I will be all right just by setting the error bars to zero.

See the doc:
The option to not draw the error bars is X.