Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15556

Re: Aspect ratio of bounding box

From Szabolcs Horvát <szhorvat@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Aspect ratio of bounding box
Date 2013-09-27 06:37 +0000
Message-ID <l23933$h74$1@smc.vnet.net> (permalink)
References <l20ov6$b77$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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.

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Aspect ratio of bounding box Themis Matsoukas <tmatsoukas@me.com> - 2013-09-26 07:49 +0000
  Re: Aspect ratio of bounding box Szabolcs Horvát <szhorvat@gmail.com> - 2013-09-27 06:37 +0000

csiph-web