Frame variable bin width

Frames have no real “binning”.

{
  const int NMbins = 5;
  double Mbins[(NMbins + 1)] = {0., 25., 50., 200., 500., 1000.};
  TH1F *hPFMET = new TH1F("hPFMET", "My Fantastic Result", NMbins, Mbins);
  TF1 *f = ((TF1*)(gROOT->GetFunction("gaus")));
  if (f) f->SetParameters(1., 150., 50.);
  hPFMET->FillRandom("gaus", 10000);
  TCanvas *c = new TCanvas("c", "c");
  c->Divide(1, 2);
  c->cd(1);
  hPFMET->Draw();
  gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
  gPad->GetFrame()->Print();
  gPad->GetFrame()->Dump();
  c->cd(2);
  TH1F *frame = gPad->DrawFrame(Mbins[0],
                                hPFMET->GetMinimum(),
                                Mbins[NMbins],
                                hPFMET->GetMaximum(),
                                hPFMET->GetTitle());
  frame->SetBins(NMbins, Mbins); // set the same bins as "hPFMET"
  gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
  gPad->GetFrame()->Print();
  gPad->GetFrame()->Dump();
  c->cd(0);
  std::cout << "hPFMET : " << hPFMET->GetNbinsY() << " x " << hPFMET->GetNbinsX() << std::endl;
  std::cout << "frame : " << frame->GetNbinsY() << " x " << frame->GetNbinsX() << std::endl;
}

See also: