Re: Aspect ratio of bounding box
- To: mathgroup at smc.vnet.net
- Subject: [mg131750] Re: Aspect ratio of bounding box
- From: Szabolcs HorvÃt <szhorvat at gmail.com>
- Date: Fri, 27 Sep 2013 02:30:32 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <l20ov6$b77$1@smc.vnet.net>
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.