MathGroup Archive 2009

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

Search the Archive

Re: How to combine Dynamic graphics in Show?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105511] Re: [mg105506] How to combine Dynamic graphics in Show?
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Sun, 6 Dec 2009 01:30:11 -0500 (EST)
  • Reply-to: jfultz at wolfram.com

Show doesn't know how to deal with something that has the head Dynamic.  If
you're going to spend time reading documentation, please make sure to read 
(again, if you've already read it before, because it's *very* relevant here) my 
post from February of this year...

http://forums.wolfram.com/mathgroup/archive/2009/Feb/msg00424.html

...which I've referenced several times on this list.  So the solution is to wrap 
the Dynamic around Show *and* to remove the Dynamic from inside of Show.

v = VerticalSlider[Dynamic[maxy], {0.1, 4}, Appearance -> "LeftArrow"];
p0 = ListPlot[Range[10]];
p1 := Plot[Cos[x], {x, -Pi, Pi}, 
   PlotRange -> {{-Pi, Pi}, {-maxy, maxy}}];
Row[{ver, Dynamic[Show[{p1, p0}]]}]

And note again (repeating the theme from the last email I just sent you) how I 
had to use SetDelayed for p1 here to make sure that things work as expected
regardless of the present global state.

Sincerely,
 
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.




On Sat, 5 Dec 2009 06:35:13 -0500 (EST), Nasser M. Abbasi wrote:
> Ver 7.
>
> Hello;
>
> Without the use of DynamicModule[], just some simple code.
>
> I have one Plot and one ListPlot, and I wanted to combine them. Ofcourse I
> can use Show[], but when one of the above objects is Dynamics, I can't do
> that. I tried many things, and so far, no success.
>
> This is what I have and what I tried:
>
> -------------------
> v = VerticalSlider[Dynamic[maxy], {0.1, 4}, Appearance -> "LeftArrow"];
> p0 = ListPlot[Range[10]];
> p1 = Dynamic[Plot[Cos[x], {x, -Pi, Pi}, PlotRange -> {{-Pi, Pi}, {-maxy,
> maxy}}]];
>
> Row[{ver, p1, p0}]
> -------------------
>
> The above works, but p1 and p0 are not combined.
>
> But I wanted to combine p1 and p0 into ONE graphics, except now this will
> not work as p1 is dynamics. I tried
>
> Row[{ver, Show[p1, p0]}]
> Row[{ver, Dynamic@Show[p1, p0]}]
>
> I really thought Dynamic[Show[....]] will do it?
>
> tried few other things....I need to read more about Dynamics, but
> meanwhile
> in case I do not see it, any idea how this can be done?
>
> Notice that  p0 is a ListPlot and not a Plot. Else I would have been able
> to
> simply use one Dynamic at Plot[...] to combine the plots and not even need
> Show[], like this (assuming the second plot is Cos[x])
>
> v = VerticalSlider[Dynamic[maxy], {0.1, 4}, Appearance -> "LeftArrow"];
> p1 = Dynamic[Plot[{Cos[x], Sin[x]}, {x, -Pi, Pi}, PlotRange -> {{-Pi,=
 Pi},
> {-maxy, maxy}}]];
> Row[{ver, p1}]
>
> and this would have worked.
>
> So, how to combine Dynamic graphics objects?
>
> thanks
> --Nasser





  • Prev by Date: Re: How to combine Dynamic graphics in Show?
  • Next by Date: Re: How to combine Dynamic graphics in Show?
  • Previous by thread: Re: How to combine Dynamic graphics in Show?
  • Next by thread: Re: How to combine Dynamic graphics in Show?