TGraph with multiple colors not working?

Hi everyone, I have an odd problem. I’m trying to overlay 4 graphs each with a different color and for some reason I can’t track down they all merge into the same color BUT the legend displays the colors correctly.
I’ve tried using Draw(), DrawGraph() and PaintGraph() to no avail. Any idea what’s wrong? All help greatly appreciated!

Here’s the program:
{
Int_t i,j,k;
ifstream fin, fin2, fin3, fin4;
fin.open(“MasterListCSB.txt”);
Int_t n=0;
// figure out how many entries in the master list
while (!fin.eof())
{
string blah;
fin >> blah;
n= n+1;
}
n= n/7;
fin.close();

// Load important entries into arrays
Double_t Run[n], FC4[n], FCCH[n], CS[n], Ratio[n], Pressure[n];
Double_t Transmission = 527.0/645.0;

string Energy;
fin2.open(“MasterListCSB.txt”);
for (i= 0; i> Run[i];
fin2 >> Energy;
fin2 >> CS[i];
fin2 >> FC4[i];
fin2 >> blah;
fin2 >> FCCH[i];
fin2 >> Pressure[i];
if (FC4[i] != 0) Ratio[i] = Transmission*FCCH[i]/FC4[i];
else Ratio[i] = 0;
cout <<Run[i] << " " << CS[i] <<" “<< FC4[i] <<” "<< FCCH[i]<< " " << Ratio[i] << " "
<< Pressure[i] << endl;
}
fin2.close();

// Make arrays of only those entries which have 1Torr and make a graph of them
Int_t T1n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] < 1.5) {T1n = T1n+1;}
}
Double_t Torr1CS[T1n], Torr1Ratio[T1n];
T1n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] < 1.5) {Torr1CS[T1n] = CS[i]; Torr1Ratio[T1n]= Ratio[i]; T1n = T1n+1;}
}
Double_t *X1T = Torr1CS;
Double_t *Y1T = Torr1Ratio;
TGraph *graph1 = new TGraph(T1n,X1T,Y1T);

// Make arrays of only those entries which have ~2 Torr and make a graph of them
Int_t T2n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] <2> 1.5) {T2n = T2n+1;} \display’s cutting out “double ampersand Pressure[i]”
}
Double_t Torr2CS[T2n], Torr2Ratio[T2n];
T2n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] <2> 1.5) {Torr2CS[T2n] = CS[i]; Torr2Ratio[T2n]= Ratio[i]; T2n = T2n+1;}
}
Double_t *X2T = Torr2CS;
Double_t *Y2T = Torr2Ratio;
TGraph *graph2 = new TGraph(T2n,X2T,Y2T);

// Make arrays of only those entries which have ~4Torr and make a graph of them
Int_t T4n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] <4> 3.5) {T4n = T4n+1;}
}
Double_t Torr4CS[T4n], Torr4Ratio[T4n];
T4n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] <4> 3.5) {Torr4CS[T4n] = CS[i]; Torr4Ratio[T4n]= Ratio[i]; T4n = T4n+1;}
}
Double_t *X4T = Torr4CS;
Double_t *Y4T = Torr4Ratio;
TGraph *graph4 = new TGraph(T4n,X4T,Y4T);

// Make arrays of only those entries which have 6Torr and make a graph of them
Int_t T6n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] <6> 5.5) {T6n = T6n+1;}
}
Double_t Torr6CS[T6n], Torr6Ratio[T6n];
T6n=0;
for(i=0;i<n;i++)
{
if ( Pressure[i] <6> 5.5) {Torr6CS[T6n] = CS[i]; Torr6Ratio[T6n]= Ratio[i]; T6n = T6n+1;}
}
Double_t *X6T = Torr6CS;
Double_t *Y6T = Torr6Ratio;
TGraph *graph6 = new TGraph(T6n,X6T,Y6T);
string names[100];
names.append(“Charge State Fractions of ^{48}Ti at “);
names.append(Energy);
names.append(” KeV/u vs Presssure”);

graph1->SetTitle(names.c_str());
graph1->GetXaxis()->SetTitle(“Charge State”);
graph1->GetXaxis()->CenterTitle();
graph1->GetYaxis()->SetTitle(“FCCH/FC4”);
graph1->GetYaxis()->SetTitleOffset(1.2);
graph1->GetYaxis()->CenterTitle();
graph1->SetLineColor(2);
graph1->SetMarkerColor(2);
graph1->SetMarkerStyle(21);
graph1->SetMarkerSize(0.6);
graph1->GetXaxis()->SetRangeUser(8,17);
graph1->Draw(“ALP”);

graph2->SetLineColor(4); // 2,4,3
graph2->SetMarkerColor(4);
graph2->SetMarkerStyle(21);
graph2->SetMarkerSize(0.6);
graph2->Draw(“LP”);

graph4->SetLineColor(3); // 2,4,3
graph4->SetMarkerColor(3);
graph4->SetMarkerStyle(21);
graph4->SetMarkerSize(0.6);
graph4->Draw(“LP”);
graph6->SetLineColor(1); // 2,4,3
graph6->SetMarkerColor(1);
graph6->SetMarkerStyle(21);
graph6->SetMarkerSize(0.6);
graph6->Draw(“LP”);

leg = new TLegend(0.65,0.65,0.89,0.89);
leg->SetHeader(“Pressure in Torr”);
leg->AddEntry(graph1,“1”,“l”);
leg->AddEntry(graph2,“2”,“l”);
leg->AddEntry(graph4,"4 ",“l”);
leg->AddEntry(graph6,“6”,“l”);

leg->Draw();

}

The text file it loads “MasterListsCSB” is as follows:
16941 920.7 17 1000 409 0 1.04053
16942 920.7 16 861 416 24 1.04029
16943 920.7 15 332 394 74 1.04233
16944 920.7 14 309.8 403 126 1.04274
16945 920.7 13 333 408 114 1.04274
16946 920.7 12 344 404 58 1.04274
16965 920.7 12 696 686 145 1.07448
16947 920.7 12 348 410 65 2.01954
16948 920.7 13 313 414 115 2.01999
16949 920.7 14 346 405 116 2.02181
16950 920.7 15 311 393 65 2.02198
16951 920.7 16 425 435 19 2.02215
16954 920.7 16 321 385 14 4.00042
16955 920.7 15 310 388 52 4.00449
16956 920.7 14 347 380 101 4.00783
16957 920.7 13 315 393 114 4.01077
16958 920.7 12 304 377 75 4.01448
16978 920.7 12 686 689 160 4.00682
16981 920.7 14 695 701 0 6.07733
16982 920.7 13 690 693 31 6.07761
16983 920.7 12 685 699 157 6.08059

I get an error on the line 95:

if ( Pressure[i] <6> 5.5) {T6n = T6n+1;}

I am not aware on a such C++ syntax. May be your code has been poluted when you copied/pasted it in the forum. Can you send you program as attachment instead of doing a copy paste ?

The editor seems to change double ampersands into deletions?
Anyhow, here’s the code attached, thanks!
AllDistributions.C (3.35 KB)

I found the error in my code… last night was a very long night… thanks regardless!

Chris

Ok good ! :slight_smile: