Hello,
I have a script which display graphs and I want to put a different color for each points. I know that with SetMarkerColor you can select the color for all points on the graph but I don’t know how can I put a different color for each points. Actually, my script display a canvas of 3 graphs and in each graph it is 3 points, I want to put 3 different colors for the 3 points on each graph.
One other thing, I want to put a grid in those graphs, I put the punction SetGrid but it don’t worked. How can I put a grid on each graph?
Thank you.
Here is my script :
char title[64];
sprintf(title,"Channel_%i -- Plots XY / YZ / XZ",TitlePlot[i]);
TCanvas *c = new TCanvas("c",title);
c->SetGrid();
c->Divide(1,3);
TGraph *CT1=new TGraph(nbpts,XG,YG);
TGraph *CT2=new TGraph(nbpts,YG,ZG);
TGraph *CT3=new TGraph(nbpts,XG,ZG);
c->cd(1); //First graph (X function of Y)
CT1->SetTitle("X function of Y");
CT1->SetMarkerStyle(19);
CT1->SetMarkerSize(2);
CT1->SetMarkerColor(31);
CT1->GetXaxis()->SetLimits(-10.0,10.0);
CT1->GetXaxis()->SetTitle("X location (µm)");
CT1->GetYaxis()->SetRangeUser(-10.,10.);
CT1->GetYaxis()->SetTitle("Y location (µm)");
CT1->Draw("A*");
c->cd(2); //Second Graph (Y function of Z)
CT2->SetTitle("Y function of Z");
CT2->SetMarkerSize(2);
CT2->SetMarkerStyle(19);
CT2->GetXaxis()->SetLimits(-10.0,10.0);
CT2->GetXaxis()->SetTitle("Y location (µm)");
CT2->GetYaxis()->SetRangeUser(-10.,10.);
CT2->GetYaxis()->SetTitle("Z location (µm)");
CT2->Draw("A*");
c->cd(3); //Third Graph (X function of Z)
CT3->SetTitle("X function of Z");
CT3->SetMarkerSize(2);
CT3->SetMarkerStyle(19);
CT3->GetXaxis()->SetLimits(-10.0,10.0);
CT3->GetXaxis()->SetTitle("X location (µm)");
CT3->GetYaxis()->SetRangeUser(-10.,10.);
CT3->GetYaxis()->SetTitle("Z location (µm)");
CT3->Draw("A*");
//c->RedrawAxis();
//Sauvegarder le canvas et le vider pr le nouveau tour de boucle
c->SaveAs(TString::Format("PLOTS/XY_YZ_XZ_Channel_%i.gif",TitlePlot[i]));
delete c;