Re: plotting with commensurate aspect ratio?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Jan 15 2000 - 11:53:09 MET


Hi Mike,
In the following macro, I show two examples.

Rene Brun

{
   gROOT->Reset();
   
   //method1. compute ymax to get a commensurate range
   // 1 pixel must correspond to the same range in x and y
   TCanvas c1("c1","c1",10,10,800,600);
   Float_t xmin = 0;
   Float_t xmax = 20;
   Float_t ymin = -2;
   Int_t npx = gPad->GetWw();
   Int_t npy = gPad->GetWh();
   Float_t ymax = ymin + (xmax-xmin)*npy/npx;
   TH2F h("h","",20,xmin,xmax,20,ymin,ymax);
   h.Draw();
   TArc a1(6,4,6);
   a1.Draw();
   
   //method2. set a square virtual canvas size in a non-square canvas 
   TCanvas c2("c2","c2",200,50,800,600);
   c2.SetCanvasSize(700,700);
   c2.DrawFrame(0,0,20,20);
   TArc a2(10,10,10);
   a2.Draw();
}

On 14 Jan 2000, Mike Miller wrote:

> >>>>> "Rene" == Rene Brun <Rene.Brun@cern.ch> writes:
> 
>     > Hi Mike, Could you clarify what you want ?  In TH1 and
>     > derived classes, you can specify an array of bin positions
>     > if you like (default being equidistant bins).
> 
>     > Mike Miller wrote:
>     >>  Is there an option that can be set so that 2d histograms
>     >> are drawn with commensurate axes?
> 
> This is not a question of defining the histogram, but of how it
> is displayed on a canvas.  I'd like to automate things so that
> h.Draw() gives me a plot on a canvas such that the horizontal and
> vertical scales are commensurate.  For example, if my histogram
> is defined like as TH2F("hist","",10,0,10,20,0.0,20.0) when it is
> plotted on the canvas, the horizontal size will be half that of
> the vertical size.  So I guess my question is really about how to
> specify the size of a histogram when it is drawn on a canvas?
> 
> Mike
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET