My code is not working

Hey! My name is Ismail.

ROOT Version: 6.22/08 - 2021-03-12

My code:

void graphpalettecolor() {
gStyle->SetOptTitle(kFALSE);
gStyle->SetPalette(kSolar);
double x[12] = { 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6};
double y1[12] = { 0.8,1.6,2.402,3.201,3.992,4.833,5.602,6.338,7.271,7.923,8.790,9.556 };
double y2[12] = { 1.23,2.46,3.7,4.93,6.17,7.41,8.64,9.88,11.11,12.34,13.58,14.81 };
TGraph* g1 = new TGraph(12, x, y1); g1->SetTitle("A");
TGraph* g2 = new TGraph(12, x, y2); g2->SetTitle("B");
g1->SetLineWidth(3); g1->SetMarkerColor(kRed);
g2->SetLineWidth(3); g2->SetMarkerStyle(kCircle);
g1->Draw("CA* PLC PFC");
g2->Draw("PC  PLC PFC");
gPad->BuildLegend();
}

When run this code, I do not get anything! No error, No graph… nothing
Why?

I can see the graph. How do you run your code?

I put your code in the graphpalettecolor.C file and did:

 root graphpalettecolor.C

It gives the plot @yus posted:

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