MathGroup Archive 2012

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

Search the Archive

Re: Drawing a Line From One Plot to Another

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127702] Re: Drawing a Line From One Plot to Another
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Wed, 15 Aug 2012 03:38:06 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20120814082121.B6E906849@smc.vnet.net>

It might be easier to use a single plot with one function offset. That
would keep you in a single set of coordinates.

y1[x_] = x^2;
y2[x_] = 2 x;

pts = {x, y1[x]} /.
   Solve[y1[x] == y2[x], x];

offset = 10;

plt = Plot[
   Evaluate[
    {Tooltip[y1[x]] ,
     Tooltip[y2[x] - offset, y2[x]]}],
   {x, -1, 3},
   Frame -> True,
   Axes -> False,
   Epilog -> {
     Text[#, #, {1, -2}] & /@ pts,
     Text[# + {0, offset}, #, {-1, 2}] & /@
      ((# - {0, offset}) & /@ pts),
     {Thick, Line[{{-1.5, -2}, {3.5, -2}}]},
     Red, AbsolutePointSize[4],
     Point[pts],
     Point[(# - {0, offset}) & /@ pts],
     Darker[Green],
     AbsoluteDashing[{10, 5}],
     Arrow[{#, # - {0, offset}}] & /@ pts}];

Show[plt, FrameTicks -> {
   Automatic,
   (FrameTicks /.
       AbsoluteOptions[plt, FrameTicks])[[2]] /.
    {y_, yl_?(NumericQ[#] && # < -1 &), r___} ->
     {y, yl + offset, r}}]

However, it may be easier still to plot the multiple functions on the
same plot. If necessary use two separate y axes (right and left frame
axes).

Plot[
 Evaluate[
  Tooltip /@
   {y1[x] , y2[x]}],
 {x, -1, 3},
 Frame -> True,
 Axes -> False,
 Epilog -> {
   Text[#, #, {-1, 2}] & /@ pts,
   Red, AbsolutePointSize[4],
   Point[pts]}]


Bob Hanlon


On Tue, Aug 14, 2012 at 4:21 AM, Gregory Lypny
<gregory.lypny at videotron.ca> wrote:
> Hello everyone,
>
> Say I have two plots, y=x^2 and y=2x, aligned vertically using GraphicsColumn.  Their domains are aligned because x runs from -3 to +3 in both. I'd like to be able to draw a line from a point in the top graph to a point in the bottom graph.  How can I do that?
>
> Regards,
>
> Gregory
>



  • Prev by Date: Re: Find Position of many elements in a large list.
  • Next by Date: Re: V8 slow like a snail
  • Previous by thread: Drawing a Line From One Plot to Another
  • Next by thread: Re: Drawing a Line From One Plot to Another