TH1F* hist = new TH1F("hist", "My histogram", 50, 0.0, 10.0); hist->FillRandom("gaus", 10000); TCanvas* canvas = new TCanvas("canvas"); hist->Draw(); canvas->SaveAs("histogram.png");
TGraph* graph = new TGraph(); for (int i = 0; i < 10; i++) { double x = i; double y = i*i; graph->SetPoint(i, x, y); } TCanvas* canvas = new TCanvas("canvas"); graph->Draw("APL"); canvas->SaveAs("graph.png");This example creates a graph with 10 points and draws it on a canvas. The Draw function is called with "APL" option, which sets drawing style to markers, lines and points. These examples use ROOT package library to create and draw data analysis plots using TCanvas Draw function.