Accomodating two graphs on the same canvas

Consider this example:

  const float x[3] = {0.0, 1.0, 2.0};
  const float y1[3] = {1.0, 1.1, 0.9};
  const float y2[3] = {3.0, 0.8, 4.5};
  TCanvas * c = new TCanvas;
  TGraph * gr1 = new TGraph(3, x, y1);
  gr1 -> SetMarkerColor(kRed);
  gr1 -> SetMarkerStyle(kCircle);
  TGraph * gr2 = new TGraph(3, x, y2);
  gr2 -> SetMarkerColor(kGreen);
  gr2 -> SetMarkerStyle(kPlus);
  gr1 -> Draw("AP");
  gr2 -> Draw("PSAME");

The output is:

  1. In the drawn axes at least the point (1.0, 0.8) of gr2 should be shown. Why is it not shown?

  2. How to best adjust the axes range to accommodate both graphs on the same canvas?

How to force the xaxis to start at -0.2, not 0.0?

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

c->DrawFrame(-0.2, 0.5, 2.2, 5.0, "Something;some x;some y");
gr1->Draw("P"); gr2->Draw("P");

See also: ROOT: TMultiGraph Class Reference

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