Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15547 > unrolled thread
| Started by | Themis Matsoukas <tmatsoukas@me.com> |
|---|---|
| First post | 2013-09-26 07:49 +0000 |
| Last post | 2013-09-27 06:37 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Themis Matsoukas <tmatsoukas@me.com> |
|---|---|
| Date | 2013-09-26 07:49 +0000 |
| Subject | Aspect ratio of bounding box |
| Message-ID | <l20ov6$b77$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | Szabolcs Horvát <szhorvat@gmail.com> |
|---|---|
| Date | 2013-09-27 06:37 +0000 |
| Message-ID | <l23933$h74$1@smc.vnet.net> |
| In reply to | #15547 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web