{
"cells": [
{
"cell_type": "markdown",
"id": "6eff06ed",
"metadata": {},
"source": [
"# gr104_palettecolor\n",
"PLC (Palette Line Color) and AMC (Palette Marker Color). \n",
"When one of these options is given to `TGraph::Draw` the `TGraph` get its color\n",
"from the current color palette defined by `gStyle->SetPalette(...)`. The color\n",
"is determined according to the number of objects having palette coloring in\n",
"the current pad.\n",
"\n",
"In this example five graphs are displayed with palette coloring for lines and\n",
"and filled area. The graphs are drawn with curves (`C` option) and one can see\n",
"the color of each graph is picked inside the palette `kSolar`. The\n",
"same is visible on filled polygons in the automatically built legend.\n",
"To have more control on the legend, it can be created manually, see the graph\n",
"tutorial gr111_legend.C\n",
"\n",
"\n",
"\n",
"**Author:** Olivier Couet \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:38 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "b1a34571",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:38:17.450706Z",
"iopub.status.busy": "2026-05-19T20:38:17.450570Z",
"iopub.status.idle": "2026-05-19T20:38:17.770251Z",
"shell.execute_reply": "2026-05-19T20:38:17.769463Z"
}
},
"outputs": [],
"source": [
"gStyle->SetOptTitle(kFALSE);\n",
"gStyle->SetPalette(kSolar);\n",
"\n",
"double x[5] = {1,2,3,4,5};\n",
"double y1[5] = {1.0,2.0,1.0,2.5,3.0};\n",
"double y2[5] = {1.1,2.1,1.1,2.6,3.1};\n",
"double y3[5] = {1.2,2.2,1.2,2.7,3.2};\n",
"double y4[5] = {1.3,2.3,1.3,2.8,3.3};\n",
"double y5[5] = {1.4,2.4,1.4,2.9,3.4};\n",
"\n",
"TGraph *g1 = new TGraph(5,x,y1); g1->SetTitle(\"Graph with a red star\");\n",
"TGraph *g2 = new TGraph(5,x,y2); g2->SetTitle(\"Graph with a circular marker\");\n",
"TGraph *g3 = new TGraph(5,x,y3); g3->SetTitle(\"Graph with an open square marker\");\n",
"TGraph *g4 = new TGraph(5,x,y4); g4->SetTitle(\"Graph with a blue star\");\n",
"TGraph *g5 = new TGraph(5,x,y5); g5->SetTitle(\"Graph with a full square marker\");\n",
"\n",
"g1->SetLineWidth(3); g1->SetMarkerColor(kRed);\n",
"g2->SetLineWidth(3); g2->SetMarkerStyle(kCircle);\n",
"g3->SetLineWidth(3); g3->SetMarkerStyle(kOpenSquare);\n",
"g4->SetLineWidth(3); g4->SetMarkerColor(kBlue);\n",
"g5->SetLineWidth(3); g5->SetMarkerStyle(kFullSquare);"
]
},
{
"cell_type": "markdown",
"id": "a1ef1db0",
"metadata": {},
"source": [
"The Draw option \"A\" (draw axes) is needed (only) for the first drawn graph"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3f1edfba",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:38:17.772587Z",
"iopub.status.busy": "2026-05-19T20:38:17.772453Z",
"iopub.status.idle": "2026-05-19T20:38:17.986035Z",
"shell.execute_reply": "2026-05-19T20:38:17.985328Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Info in : created default TCanvas with name c1\n"
]
}
],
"source": [
"g1->Draw(\"CA* PLC PFC\");\n",
"g2->Draw(\"PC PLC PFC\");\n",
"g3->Draw(\"PC PLC PFC\");\n",
"g4->Draw(\"*C PLC PFC\");\n",
"g5->Draw(\"PC PLC PFC\");\n",
"\n",
"gPad->BuildLegend();"
]
},
{
"cell_type": "markdown",
"id": "ff79eb9c",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "bf7ba349",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:38:17.987817Z",
"iopub.status.busy": "2026-05-19T20:38:17.987680Z",
"iopub.status.idle": "2026-05-19T20:38:18.203484Z",
"shell.execute_reply": "2026-05-19T20:38:18.203067Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"gROOT->GetListOfCanvases()->Draw()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ROOT C++",
"language": "c++",
"name": "root"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".C",
"mimetype": " text/x-c++src",
"name": "c++"
}
},
"nbformat": 4,
"nbformat_minor": 5
}