void draw_histogram() { // create a histogram TH1F *hist = new TH1F("hist", "Example Histogram", 100, 0, 100); // fill the histogram hist->Fill(30); hist->Fill(50); hist->Fill(70); // create a canvas TCanvas *canvas = new TCanvas("canvas"); // draw the histogram on the canvas hist->Draw(); // get the frame TFrame *frame = canvas->GetFrame(); // set the axis titles frame->GetXaxis()->SetTitle("X Axis"); frame->GetYaxis()->SetTitle("Y Axis"); }
void draw_arrow() { // create a canvas TCanvas *canvas = new TCanvas("canvas"); // draw an arrow on the canvas TArrow *arrow = new TArrow(0, 0, 1, 1, 0.02, "|>"); arrow->Draw(); // get the frame TFrame *frame = canvas->GetFrame(); // set the axis ranges frame->SetX1(-1); frame->SetX2(2); frame->SetY1(-1); frame->SetY2(2); }In this example, we create an arrow on a canvas and use the GetFrame method to obtain a pointer to the canvas frame. We then use the SetX1, SetX2, SetY1, and SetY2 methods to adjust the axis ranges of the frame. Overall, the TCanvas GetFrame method is a useful tool for adjusting the appearance of a canvas frame in ROOT-based projects.