TCanvas *canvas = new TCanvas("canvas", "Graph", 800, 600); TGraph *graph = new TGraph(); graph->SetPoint(0, 1, 2); graph->SetPoint(1, 2, 3); graph->SetPoint(2, 3, 4); graph->Draw("ACP"); canvas->Update();
TCanvas *canvas = new TCanvas("canvas", "Histogram", 800, 600); TH1F *hist = new TH1F("hist", "Distribution", 100, -3, 3); hist->FillRandom("gaus", 10000); hist->Draw(); TF1 *fit = new TF1("fit", "gaus", -3, 3); hist->Fit(fit); fit->Draw("same"); canvas->Update();This code creates a canvas, creates a histogram object, fills it with 10000 random numbers from a Gaussian distribution, draws the histogram, fits a Gaussian function to the histogram, and then draws the fit line on top of the histogram.