Multigraph without same size

Hello to everybody!!!

I am trying to make two plots in one graph, so I am using multigraph.
The thing is that the two data sets are of different dimensions.
I believe that’s the main reason the following code isn’t working, as the very exact code works like a charm with same-size data.

[code]# include “TCanvas.h”

include “TROOT.h”

include “TGraphErrors.h”

include “TF1.h”

include “TLegend.h”

include “TArrow.h”

include “TLatex.h”

void gain(){

TCanvas *c = new TCanvas("c","c",1000, 1000);
TMultiGraph * mg = new TMultiGraph("gain curve","GAIN CURVE");

// The values on the Y axis
const int n_Fe=12;
double x_Fe[n_Fe]={600,605,610,615,620,625,630,635,640,645,650,655};
double y_Fe[n_Fe]={3057,3477,3897,4436,5096,5755,6475,7374,8513,9532,10851,12230};

const int n_alpha=9;
double x_alpha[n_alpha]={500,535,540,545,550,555,560,565,570};
double y_alpha[n_alpha]={220,490,556,622,710,754,849,959,1098};

TGraph * gr1 = new TGraph( n_Fe, x_Fe, y_Fe );
gr1->SetName(“gr1”);
gr1->SetTitle(“Fe”);
gr1->SetMarkerStyle(21);
gr1->SetDrawOption(“AP”);
gr1->SetLineColor(2);
gr1->SetLineWidth(4);
gr1->SetFillStyle(0);

TGraph * gr2 = new TGraph( n_alpha, x_alpha, y_alpha );
gr2->SetName(“gr2”);
gr2->SetTitle(“alpha”);
gr2->SetMarkerStyle(22);
gr2->SetMarkerColor(2);
gr2->SetDrawOption(“P”);
gr2->SetLineColor(3);
gr2->SetLineWidth(4);
gr2->SetFillStyle(0);

mg->Add(gr1);
gr2->Draw(“ALP”);
mg->Draw(“LP”);
c->BuildLegend();

}
[/code]

Any ideas?

Instead of: mg->Add(gr1); gr2->Draw("ALP"); mg->Draw("LP"); use: mg->Add(gr1); mg->Add(gr2); mg->Draw("ALP");

You are ABSOLUTELY right!
Thank you very much for your help…
Silly me :blush: