Generate two figures of different origins on same canvas

I have a small issue that I haven’t found an answer to on the manual.
I have two data sets of points that I want to plot on the same canvas. I would like to visualize the first data set in blue, and the second one in red; here are the very easy commands that I’m using:

TGraph g("RedArray.txt")
g.SetMarkerColor(kRed)
TGraph gr("BlueArray.txt")
gr.SetMarkerColor(kBlue)
g.Draw()
gr.Draw()

This, of course, draws the two figures on two different pages. How could I merge both to have the blue and the red arrays in the same figure?

Thank you.

   TGraph gr("RedArray.txt");
   gr.SetMarkerColor(kRed);
   gr.SetMarkerStyle(20);
   gr.SetLineColor(kRed);
   
   TGraph gb("BlueArray.txt");
   gb.SetMarkerColor(kBlue);
   gb.SetLinerColor(kBlue);
   gb.SetMarkerStyle(21);

   gr.Draw("alp");
   gb.Draw("lp");
1 Like

Thank you! It worked!

I’m facing another issue. Several people have asked the same question but I can’t seem to solve it:
I’m somehow not able to set the Axis Range. Is it possible to change it manually from the figure (from what I’ve seen it is not); otherwise, how could I change my code to set the X axis range between two different points?

https://root.cern.ch/how/how-set-ranges-axis

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.