TGraph title and axis problems

{
  const Int_t n = 20;
  Double_t x[n], y[n];
  for (Int_t i = 0; i < n; i++) {
    x[i] = i * 0.1 + 0.05;
    y[i] = 10.0 * sin(x[i] + 0.2);
  }
  TGraph *gr = new TGraph(n, x, y);
  TCanvas *c1 = new TCanvas("c1", "c1");
  TH1F *hf = gPad->DrawFrame(0., 1., 3., 12., // xmin, ymin, xmax, ymax
                             "global title;X title;Y title;Z title");
  gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
#if 0 /* 0 or 1 */
  hf = ((TH1F *)(gPad->FindObject("hframe")));
#endif /* 0 or 1 */
  // hf->SetTitle("novel global title;novel X title;novel Y title;novel Z title");
  gr->Draw("*");
  // hf->SetTitle("new global title;new X title;new Y title;new Z title");
  gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
}[/code] [code]{
  const Int_t n = 20;
  Double_t x[n], y[n];
  for (Int_t i = 0; i < n; i++) {
    x[i] = i * 0.1 + 0.05;
    y[i] = 10.0 * sin(x[i] + 0.2);
  }
  TGraph *gr = new TGraph(n, x, y);
  TMultiGraph *mg = new TMultiGraph("mg",
                                    "global title;X title;Y title;Z title");
  mg->Add(gr, "*");
  TCanvas *c1 = new TCanvas("c1", "c1");
  // mg->SetTitle("novel global title;novel X title;novel Y title;novel Z title");
  mg->Draw("A");
  gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
  // mg->GetHistogram()->SetTitle("new title;new X title;new Y title;new Z title");
#if 1 /* 0 or 1 */
  mg->GetXaxis()->SetLimits(0., 3.); // xmin, xmax
  mg->GetHistogram()->SetMinimum(1.); // ymin
  mg->GetHistogram()->SetMaximum(12.); // ymax
#else /* 0 or 1 */
  mg->GetXaxis()->SetLimits(0., 3.); // xmin, xmax
  mg->GetYaxis()->SetRangeUser(1., 12.); // ymin, ymax
  // mg->GetHistogram()->SetAxisRange(1., 12., "Y"); // ymin, ymax
#endif /* 0 or 1 */
  gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
}

See also:
https://root-forum.cern.ch/t/order-of-calling-methods-with-tmultigraph/14724/2
https://root-forum.cern.ch/t/setting-titles-for-tgraphs/14856/1
https://root-forum.cern.ch/t/setrangeuser-and-settitle-working-with-thstacks-and-th1f-obj/12114/1
https://root-forum.cern.ch/t/setaxisrange-0-0-1-0-y-is-ineffective/14040/1
https://root-forum.cern.ch/t/palette-on-a-tprofile2d/14704/1
https://root-forum.cern.ch/t/setrangeuser-doesnt-work-well/14774/1
https://root-forum.cern.ch/t/drawing-a-tgraphasymmerrors/14205/1