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


Groups > comp.soft-sys.math.mathematica > #7067 > unrolled thread

Precicely defining plot size

Started bypremiumxy <spam@stefanabel.com>
First post2011-12-09 10:59 +0000
Last post2011-12-11 08:49 +0000
Articles 5 — 4 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Precicely defining plot size premiumxy <spam@stefanabel.com> - 2011-12-09 10:59 +0000
    Re: Precicely defining plot size Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-12-10 12:32 +0000
    Re: Precicely defining plot size Mike H <mike.honeychurch@gmail.com> - 2011-12-11 08:52 +0000
    Re: Precicely defining plot size DrMajorBob <btreat1@austin.rr.com> - 2011-12-11 08:53 +0000
    Re: Precicely defining plot size DrMajorBob <btreat1@austin.rr.com> - 2011-12-11 08:49 +0000

#7067 — Precicely defining plot size

Frompremiumxy <spam@stefanabel.com>
Date2011-12-09 10:59 +0000
SubjectPrecicely defining plot size
Message-ID<jbspm1$3r9$1@smc.vnet.net>
Hello,

I have layout problem, and I just cannot get it solved even after trying for a long time now...

To make it simple: I want to create a plot with frame->true (that I afterwards export to a *.eps file) with a precise frame size, let's say 2inch.

Plot[Sin[x],{x,0,10},ImageSize->144]

How do you have access to the frame size within a plot?! I know that by ImageSize->144 the whole image will be 2inch large. But this includes the ticks and the frame-labels. I can make paddings, or reduce the plotRegion, but always including the labels...

It sounds like an easy problem. Has anybody an idea?

Thanks a lot!

[toc] | [next] | [standalone]


#7082

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-12-10 12:32 +0000
Message-ID<jbvjhf$ivv$1@smc.vnet.net>
In reply to#7067
On Dec 9, 9:59 pm, premiumxy <s...@stefanabel.com> wrote:
> Hello,
>
> I have layout problem, and I just cannot get it solved even after trying for a long time now...
>
> To make it simple: I want to create a plot with frame->true (that I after wards export to a *.eps file) with a precise frame size, let's say 2inch.
>
> Plot[Sin[x],{x,0,10},ImageSize->144]
>
> How do you have access to the frame size within a plot?! I know that by I mageSize->144 the whole image will be 2inch large. But this includes the ticks and the frame-labels. I can make paddings, or reduce the plotRegion, but always including the labels...
>
> It sounds like an easy problem. Has anybody an idea?
>
> Thanks a lot!

With an ImageSize of 144 the frame will only be 144 if ImagePadding is
zero. So what you need to do is explicitly set some image padding and
add that to the "frame size" to get your final image size:

(* padding *)
{{l, r}, {b, t}} = {{30, 30}, {30, 30}};

(* amount this adds to the size *)
{w, h} = Total /@ {{l, r}, {b, t}};

(* aspect ratio *)
aspectratio = 1./GoldenRatio;

(* frame size *)
framesize = {144, 144*aspectratio}

Plot[Sin[x], {x, 0, 10},
 Frame -> True,
 ImageSize -> framesize + {w, h},
 ImagePadding -> {{l, r}, {b, t}}]

This is also important in dynamic plots when you are resizing -- it
allows you to keep everything a fixed size or alternatively you can
resize will scale everything correctly.

Mike
http://ibnhconsulting.blogspot.com/

[toc] | [prev] | [next] | [standalone]


#7111

FromMike H <mike.honeychurch@gmail.com>
Date2011-12-11 08:52 +0000
Message-ID<jc1r12$t1m$1@smc.vnet.net>
In reply to#7067
Bobby,

This has been my default plotting construct for ages and ages. It works
fine. The way I read the question was the guy wanted an exact frame size of
144 for the plot Frame. All your variations of my example deliver that
...for the x axis at least.

My example used the default aspect ratio. If you alter that in the
preliminary calculations then for aesthetics you should also alter than in
the Plot options, and in fact I meant to add that anyway:

(*padding*){{l, r}, {b, t}} = {{30, 30}, {30, 30}};

(*amount this adds to the size*)
{w, h} = Total /@ {{l, r}, {b, t}};

(*aspect ratio*)
aspectratio = 1./GoldenRatio;

(*frame size*)
framesize = {144, 144*aspectratio}

Plot[Sin[x], {x, 0, 10}, AspectRatio -> aspectratio, Frame -> True,
 ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]

If the user wants a frame that is 144 in each direction then set
aspectratio=1.


Mike


On Sun, Dec 11, 2011 at 6:25 AM, DrMajorBob <btreat1@austin.rr.com> wrote:

> Armand,
>
> I don't think that's quite doing what you think. Compare these plots to
> see why:
>
> {{l, r}, {b, t}} = {{30, 30}, {30, 30}};
> {w, h} = Total /@ {{l, r}, {b, t}};
> aspectRatio = 1/GoldenRatio;
> framesize = 144 {1, aspectRatio};
> Plot[Sin[x], {x, 0, 10}, Frame -> True,
>  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]
>
> aspectRatio = .5/GoldenRatio;
> framesize = 144 {1, aspectRatio};
> Plot[Sin[x], {x, 0, 10}, Frame -> True,
>  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]
>
> aspectRatio = 3/GoldenRatio;
> framesize = 144 {1, aspectRatio};
> Plot[Sin[x], {x, 0, 10}, Frame -> True,
>  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]
>
> Bobby
>
> On Sat, 10 Dec 2011 06:27:59 -0600, Armand Tamzarian <
> mike.honeychurch@gmail.com> wrote:
>
>  On Dec 9, 9:59 pm, premiumxy <s...@stefanabel.com> wrote:
>>
>>> Hello,
>>>
>>> I have layout problem, and I just cannot get it solved even after trying
>>> for a long time now...
>>>
>>> To make it simple: I want to create a plot with frame->true (that I
>>> after wards export to a *.eps file) with a precise frame size, let's say
>>> 2inch.
>>>
>>> Plot[Sin[x],{x,0,10},**ImageSize->144]
>>>
>>> How do you have access to the frame size within a plot?! I know that by
>>> I mageSize->144 the whole image will be 2inch large. But this includes the
>>> ticks and the frame-labels. I can make paddings, or reduce the plotRegion,
>>> but always including the labels...
>>>
>>> It sounds like an easy problem. Has anybody an idea?
>>>
>>> Thanks a lot!
>>>
>>
>> With an ImageSize of 144 the frame will only be 144 if ImagePadding is
>> zero. So what you need to do is explicitly set some image padding and
>> add that to the "frame size" to get your final image size:
>>
>> (* padding *)
>> {{l, r}, {b, t}} = {{30, 30}, {30, 30}};
>>
>> (* amount this adds to the size *)
>> {w, h} = Total /@ {{l, r}, {b, t}};
>>
>> (* aspect ratio *)
>> aspectratio = 1./GoldenRatio;
>>
>> (* frame size *)
>> framesize = {144, 144*aspectratio}
>>
>> Plot[Sin[x], {x, 0, 10},
>>  Frame -> True,
>>  ImageSize -> framesize + {w, h},
>>  ImagePadding -> {{l, r}, {b, t}}]
>>
>> This is also important in dynamic plots when you are resizing -- it
>> allows you to keep everything a fixed size or alternatively you can
>> resize will scale everything correctly.
>>
>> Mike
>> http://ibnhconsulting.**blogspot.com/<http://ibnhconsulting.blogspot.com/>
>>
>>
>
> --
> DrMajorBob@yahoo.com
>

[toc] | [prev] | [next] | [standalone]


#7112

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-12-11 08:53 +0000
Message-ID<jc1r21$t1t$1@smc.vnet.net>
In reply to#7067
With AspectRatio -> aspectratio added, the results make sense.

Bobby

On Sat, 10 Dec 2011 14:50:00 -0600, Mike H <mike.honeychurch@gmail.com>  
wrote:

> Bobby,
>
> This has been my default plotting construct for ages and ages. It works
> fine. The way I read the question was the guy wanted an exact frame size  
> of
> 144 for the plot Frame. All your variations of my example deliver that
> ...for the x axis at least.
>
> My example used the default aspect ratio. If you alter that in the
> preliminary calculations then for aesthetics you should also alter than  
> in
> the Plot options, and in fact I meant to add that anyway:
>
> (*padding*){{l, r}, {b, t}} = {{30, 30}, {30, 30}};
>
> (*amount this adds to the size*)
> {w, h} = Total /@ {{l, r}, {b, t}};
>
> (*aspect ratio*)
> aspectratio = 1./GoldenRatio;
>
> (*frame size*)
> framesize = {144, 144*aspectratio}
>
> Plot[Sin[x], {x, 0, 10}, AspectRatio -> aspectratio, Frame -> True,
>  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]
>
> If the user wants a frame that is 144 in each direction then set
> aspectratio=1.
>
>
> Mike
>
>
> On Sun, Dec 11, 2011 at 6:25 AM, DrMajorBob <btreat1@austin.rr.com>  
> wrote:
>
>> Armand,
>>
>> I don't think that's quite doing what you think. Compare these plots to
>> see why:
>>
>> {{l, r}, {b, t}} = {{30, 30}, {30, 30}};
>> {w, h} = Total /@ {{l, r}, {b, t}};
>> aspectRatio = 1/GoldenRatio;
>> framesize = 144 {1, aspectRatio};
>> Plot[Sin[x], {x, 0, 10}, Frame -> True,
>>  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]
>>
>> aspectRatio = .5/GoldenRatio;
>> framesize = 144 {1, aspectRatio};
>> Plot[Sin[x], {x, 0, 10}, Frame -> True,
>>  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]
>>
>> aspectRatio = 3/GoldenRatio;
>> framesize = 144 {1, aspectRatio};
>> Plot[Sin[x], {x, 0, 10}, Frame -> True,
>>  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]
>>
>> Bobby
>>
>> On Sat, 10 Dec 2011 06:27:59 -0600, Armand Tamzarian <
>> mike.honeychurch@gmail.com> wrote:
>>
>>  On Dec 9, 9:59 pm, premiumxy <s...@stefanabel.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> I have layout problem, and I just cannot get it solved even after  
>>>> trying
>>>> for a long time now...
>>>>
>>>> To make it simple: I want to create a plot with frame->true (that I
>>>> after wards export to a *.eps file) with a precise frame size, let's  
>>>> say
>>>> 2inch.
>>>>
>>>> Plot[Sin[x],{x,0,10},**ImageSize->144]
>>>>
>>>> How do you have access to the frame size within a plot?! I know that  
>>>> by
>>>> I mageSize->144 the whole image will be 2inch large. But this  
>>>> includes the
>>>> ticks and the frame-labels. I can make paddings, or reduce the  
>>>> plotRegion,
>>>> but always including the labels...
>>>>
>>>> It sounds like an easy problem. Has anybody an idea?
>>>>
>>>> Thanks a lot!
>>>>
>>>
>>> With an ImageSize of 144 the frame will only be 144 if ImagePadding is
>>> zero. So what you need to do is explicitly set some image padding and
>>> add that to the "frame size" to get your final image size:
>>>
>>> (* padding *)
>>> {{l, r}, {b, t}} = {{30, 30}, {30, 30}};
>>>
>>> (* amount this adds to the size *)
>>> {w, h} = Total /@ {{l, r}, {b, t}};
>>>
>>> (* aspect ratio *)
>>> aspectratio = 1./GoldenRatio;
>>>
>>> (* frame size *)
>>> framesize = {144, 144*aspectratio}
>>>
>>> Plot[Sin[x], {x, 0, 10},
>>>  Frame -> True,
>>>  ImageSize -> framesize + {w, h},
>>>  ImagePadding -> {{l, r}, {b, t}}]
>>>
>>> This is also important in dynamic plots when you are resizing -- it
>>> allows you to keep everything a fixed size or alternatively you can
>>> resize will scale everything correctly.
>>>
>>> Mike
>>> http://ibnhconsulting.**blogspot.com/<http://ibnhconsulting.blogspot.com/>
>>>
>>>
>>
>> --
>> DrMajorBob@yahoo.com
>>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [next] | [standalone]


#7131

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-12-11 08:49 +0000
Message-ID<jc1qqc$svd$1@smc.vnet.net>
In reply to#7067
Armand,

I don't think that's quite doing what you think. Compare these plots to  
see why:

{{l, r}, {b, t}} = {{30, 30}, {30, 30}};
{w, h} = Total /@ {{l, r}, {b, t}};
aspectRatio = 1/GoldenRatio;
framesize = 144 {1, aspectRatio};
Plot[Sin[x], {x, 0, 10}, Frame -> True,
  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]

aspectRatio = .5/GoldenRatio;
framesize = 144 {1, aspectRatio};
Plot[Sin[x], {x, 0, 10}, Frame -> True,
  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]

aspectRatio = 3/GoldenRatio;
framesize = 144 {1, aspectRatio};
Plot[Sin[x], {x, 0, 10}, Frame -> True,
  ImageSize -> framesize + {w, h}, ImagePadding -> {{l, r}, {b, t}}]

Bobby

On Sat, 10 Dec 2011 06:27:59 -0600, Armand Tamzarian  
<mike.honeychurch@gmail.com> wrote:

> On Dec 9, 9:59 pm, premiumxy <s...@stefanabel.com> wrote:
>> Hello,
>>
>> I have layout problem, and I just cannot get it solved even after  
>> trying for a long time now...
>>
>> To make it simple: I want to create a plot with frame->true (that I  
>> after wards export to a *.eps file) with a precise frame size, let's  
>> say 2inch.
>>
>> Plot[Sin[x],{x,0,10},ImageSize->144]
>>
>> How do you have access to the frame size within a plot?! I know that by  
>> I mageSize->144 the whole image will be 2inch large. But this includes  
>> the ticks and the frame-labels. I can make paddings, or reduce the  
>> plotRegion, but always including the labels...
>>
>> It sounds like an easy problem. Has anybody an idea?
>>
>> Thanks a lot!
>
> With an ImageSize of 144 the frame will only be 144 if ImagePadding is
> zero. So what you need to do is explicitly set some image padding and
> add that to the "frame size" to get your final image size:
>
> (* padding *)
> {{l, r}, {b, t}} = {{30, 30}, {30, 30}};
>
> (* amount this adds to the size *)
> {w, h} = Total /@ {{l, r}, {b, t}};
>
> (* aspect ratio *)
> aspectratio = 1./GoldenRatio;
>
> (* frame size *)
> framesize = {144, 144*aspectratio}
>
> Plot[Sin[x], {x, 0, 10},
>  Frame -> True,
>  ImageSize -> framesize + {w, h},
>  ImagePadding -> {{l, r}, {b, t}}]
>
> This is also important in dynamic plots when you are resizing -- it
> allows you to keep everything a fixed size or alternatively you can
> resize will scale everything correctly.
>
> Mike
> http://ibnhconsulting.blogspot.com/
>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web