Obtain height of a frame from canvas

Hello,

I would like to obtain the height of a frame (the fY2 variable in the Inspector) given just a canvas. I have tried various combinations of:
fY2 = canvas -> GetSelectedPad() -> GetFrame() -> GetY2()

For example, in the code below, the value of frame_fy2 should be about 700.

Thanks a lot!!

Pat

main()
{

  c1 = new TCanvas("c1","Test Canvas",200,10,600,400);
  c1 -> Divide(1,1,0.01,0.01);

  // Create histogram
  TH1F* hist = new TH1F("h1","Random Gaussian",50,-4,4);
  hist->FillRandom("gaus",10000);

  // Plot
  c1 -> cd(1);
  hist -> SetMarkerStyle(20);
  hist -> DrawCopy("P");
  hist -> SetDirectory(NULL); 

  // Does not work
  Float_t frame_fy2;
  frame_fy2 = ( (c1 -> GetSelectedPad()) -> GetFrame() ) -> GetY2();

} //main

Hi Pat,
use gPad->GetFrame()->GetY2() or c1->Pad()->GetFrame()->GetY2().

root [12] gPad->GetFrame()->Dump() ==> Dumping object at: 0x10e54f00, name=TFrame, class=TFrame [...] fY2 719.25 Y of 2nd point [...] root [13] gPad->GetFrame()->GetY2() (const Double_t)7.19250000000000000e+02
Axel.

And do not forget gPad->Update():

{
   c1 = new TCanvas("c1","Test Canvas",200,10,600,400);
 
   // Create histogram
   TH1F* hist = new TH1F("h1","Random Gaussian",50,-4,4);
   hist->FillRandom("gaus",10000);
 
   // Plot
   c1 -> cd(1);
   hist -> SetMarkerStyle(20);
   hist -> DrawCopy("P");
   hist -> SetDirectory(NULL);
 
   // Does work
   gPad->Update();
   TFrame *f = gPad->GetFrame();    

   printf("%g\n",f->GetY2());      
}