MathGroup Archive 2009

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

Search the Archive

Re: Combine images, Show[] and its effect on AspectRatio. Plot, Epilog,

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105486] Re: Combine images, Show[] and its effect on AspectRatio. Plot, Epilog,
  • From: dh <dh at metrohm.com>
  • Date: Fri, 4 Dec 2009 04:34:47 -0500 (EST)
  • References: <hf2mqp$id6$1@smc.vnet.net> <4B14FCDE.90001@metrohm.com> <hf5j5k$qj4$1@smc.vnet.net>


Nasser M. Abbasi wrote:

> "dh" <dh at metrohm.com> wrote in message news:4B14FCDE.90001 at metrohm.com...

>> Hi Nasser,

>> the circle is drawn in the coordinate system of the plot. Therefore, you 

>> need to draw the circle as an ellipss in the "Plot" coordinate system. 

>> This can be done by a scaling transformation that takes care of the aspect 

>> ratio:

>>

>> cir = Circle[{0, 0}, 1, {-45 Degree, 180 Degree}];

>> pl = Plot[Sin[x], {x, -Pi, Pi}];

>> asp = AspectRatio /. FullOptions[pl];

>> tr = ScalingTransform[{1/asp, 1}];

>> cir = Graphics@GeometricTransformation[cir, tr];

>> Show[pl, cir]

>>

> 

> Hi Daniel;

> 

> Notice what I changed the plot range, the circle no longer comes out 

> circular looking. Below I made the plot to go from -5Pi to +5Pi

> 

> cir=Circle[{0,0},1,{-45 Degree,180 Degree}];

> pl=Plot[Sin[x],{x,-5Pi,5 Pi}];

> asp=AspectRatio/.FullOptions[pl];

> tr=ScalingTransform[{1/asp,1}];

> cir=Graphics@GeometricTransformation[cir,tr];

> Show[pl,cir]

> 

> It happens to work ok when the plot range was {-Pi,Pi} (same for the post I 

> just send, which worked for only -Pi,Pi, so I still need to work on this 

> more!), but not for other plots ranges.

> 

> thanks

> --Nasser

> 

> 

> 

Hi Nasser,

you are right, we not only need to take into consideration the aspect 

ratio but also the plot range. The solution with inset is certainly 

simpler, but for the heck of it, here is a solution:



cir = Circle[{0, 0}, 1, {-45 Degree, 180 Degree}];

pl = Plot[Sin[x], {x, -5 Pi, 5 Pi}];

plr = PlotRange /. FullOptions[pl];

asp = AspectRatio /. FullOptions[pl];

plr = (plr[[2, 2]] - plr[[2, 1]])/(plr[[1, 2]] - plr[[1, 1]]);

tr = ScalingTransform[{asp/plr, 1}];

cir = Graphics@GeometricTransformation[cir, tr];

Show[pl, cir]



Daniel




  • Prev by Date: Re: Re: piecewice pdf, problems with cdf
  • Next by Date: Re: How to make large graphics object fit within a plot?
  • Previous by thread: Re: Combine images, Show[] and its effect on AspectRatio. Plot, Epilog,
  • Next by thread: Re: Combine images, Show[] and its effect on