MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Aspect ratio of bounding box

  • To: mathgroup at
  • Subject: [mg131750] Re: Aspect ratio of bounding box
  • From: Szabolcs HorvÃt <szhorvat at>
  • Date: Fri, 27 Sep 2013 02:30:32 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <l20ov6$b77$>

On 2013-9-26 3:49 , Themis Matsoukas wrote:
> Is it possible to specify the aspect ratio of the bounding box that is produced by Plot/ListPlot etc?
> If this is not possible, can I at least obtain the dimensions of the bounding box after the plot has been rendered?
> Thanks

The options AspectRatio will specify the aspect ratio of the plot region 
only, not the bounding box:

plot = Plot[Sin[x],{x,0,10}, AspectRatio -> 1/2]

Once you have the graphics, you can query the full bounding box size using

Rasterize[plot, "RasterSize"]

(Rasterize[plot, "BoundingBox"] will also give the baseline offset, 
which you probably don't need.)

In this case I got {360, 176}, which is different from a ratio of 1/2. 
This is because of the ticks added outside of the plot region.

If you need to start with the aspect ratio of the bounding box, you can 
do something like

plot = Plot[Sin[x], {x, 0, 10}, AspectRatio -> 1/2,
   ImageSize -> {360, 180}]

Note that this will change the margins outside the graphics.  It adds a 
bit of extra padding.

Also note that this is unfortunately not 100% reliable.  The actual 
image size may not be equal to the requested image size. It may be off 
by a couple of pixels.

  • Prev by Date: Create a Nasty Password with MATHEMATICA
  • Next by Date: Re: Cyclic generator of a cyclic expression
  • Previous by thread: Aspect ratio of bounding box
  • Next by thread: Re: Aspect ratio of bounding box