How to adjust range in canvas?

I’m afraid each canvas / pad will have a different name for its “frame” histogram and so you need to play a bit with the TList returned by the “TList *l = c->GetListOfPrimitives();” in order to find it (for example, find the first key which name begins with “frame_” or maybe it’s sufficient to find the first key which is a TH1D or maybe it’s simply always the second key in the list). Your attached “file.root” has a “frame_2a3b440”.

[code]#include “TFile.h”
#include “TCanvas.h”
#include “TH1.h”
#include

void make_plots(std::string ifile)
{
TFile f(ifile.c_str(),“read”);

TCanvas c = (TCanvas)f.Get(“test_can”);
c->SetLogy();

// c->Draw();
// c->GetListOfPrimitives()->ls();
// c->GetListOfPrimitives()->Print();

TH1D *h = (TH1D *)c->GetPrimitive(“frame_2a3b440”);
h->SetAxisRange(0, 20, “X”);
h->SetAxisRange(1e-4, 2, “Y”);
// h->SetXTitle(“Something?”);
h->SetYTitle(“What’s this?”);

c->Modified(); c->Update();
std::string pdf_name = ifile + string(".pdf");
c->SaveAs(pdf_name.c_str());
}[/code]