Tgrapg Marker always with Line

Hi,

This might be a very easy question, but I’m unable to solve it.

When plotting multiple data with TGraph I cannot get a continuous line for one set of data and only markers for another one. If I set the “ACP” option, the markers come with a line, which I wouldn’t like to.

I’m attaching the graph I get with the following piece of code:

TCanvas *c6 = new TCanvas(“c6”);
c6->SetFillColor(10);
c6->SetGrid();
c6->SetLogx();
c6->SetLogy();

TMultiGraph *mg = new TMultiGraph();

TGraph *Gra1 = new TGraph(“Tungsten/Electron/Electron_Tungsten.dat”,"%lg %lg");
Gra1->SetLineColor(4);
Gra1->SetLineWidth(4);

TGraph *Gra2 = new TGraph(37,energy,electron_Tungsten_stopping_power);
Gra2->SetMarkerColor(2);
Gra2->SetMarkerStyle(21);
Gra2->SetMarkerSize(1.2);

mg->Add(Gra1);
mg->Add(Gra2);
mg->Draw(“ACP”);

mg->SetTitle(“Tungsten Stopping Power for Electrons”);
mg->GetXaxis()->SetTitle(“Energy[MeV]”);
mg->GetYaxis()->SetTitle(“Stopping Power [MeV.cm2/g]”);

gPad->Modified();

leg = new TLegend(0.1,0.7,0.3,0.9);
leg->SetFillColor(0);
leg->AddEntry(Gra1,“NIST Database”,“l”);
leg->AddEntry(Gra2,“GEANT4”,“p”);
leg->Draw();

Thanks a lot.
Leonardo


Hi Leonardo,

try replacing the

mg->Add(Gra1);
mg->Add(Gra2);
mg->Draw("ACP");

with

mg->Add(Gra1, "cp");
mg->Add(Gra2, "p");
mg->Draw("a");

Thanks a lot!! It worked just as I expected.

Best Regards