TCanvas* c = new TCanvas("c", "Graphs", 600, 400); TGraph* g1 = new TGraph(n, x, y1); TGraph* g2 = new TGraph(n, x, y2); TLegend* leg = new TLegend(0.7, 0.7, 0.9, 0.9); leg->AddEntry(g1, "Graph 1", "l"); leg->AddEntry(g2, "Graph 2", "l"); leg->Draw(); g1->Draw("same"); g2->Draw("same"); c->Update();
TCanvas* c = new TCanvas("c", "Graphs", 600, 400); TGraph* g1 = new TGraph(n, x, y1); TGraph* g2 = new TGraph(n, x, y2); TLegend* leg = new TLegend(0.7, 0.7, 0.9, 0.9); leg->AddEntry(g1, "Graph 1", "lep"); leg->AddEntry(g2, "Graph 2", "lep"); leg->Draw(); g1->SetMarkerStyle(20); g1->Draw("p same"); g2->SetMarkerStyle(21); g2->Draw("p same"); c->Update();This example is similar to the previous one, but instead of using a line for each graph, we use circular markers with different styles. We set the `MarkerStyle` property for each graph and add the `p` option to the `Draw` method to plot the markers. Package/library: ROOT C++ library.