MathGroup Archive 2008

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

Search the Archive

RE: Dynamic Show in Manipulate

  • To: mathgroup at
  • Subject: [mg94063] RE: [mg94041] Dynamic Show in Manipulate
  • From: "David Park" <djmpark at>
  • Date: Thu, 4 Dec 2008 07:12:51 -0500 (EST)
  • References: <3853415.1228302997655.JavaMail.root@m02>


This is a case where Manipulate is difficult (although maybe someone has a
method) but it is very easy to construct an efficient dynamic display using
the Presentations package.

This uses Version 7 where VectorPlot replaces the routine in the
VectorFieldPlots package.



 {k = 1},
  {phrase["k: ", Slider[Dynamic[k], {1, 10}], Spacer[5], 
    InputField[Dynamic[k], FieldSize -> {4, 1.2}]],
    {Gray, background,
     Red, Thick,
     Dynamic@Draw[Cos[x], {x, -5, -5 + k}]},
    Frame -> True,
    ImageSize -> 300]},
  Style["Dynamic Curve on Background", 16],
  paneWidth -> All

I made the background vector plot gray and the curve Red and Thick. The k
Slider and the alternative InputField for k appear at the top. Only the
curve is Dynamic and the slider works instantaneously without redrawing the
background plot.

David Park
djmpark at 

From: Michael Hsieh [mailto:JiaYow at] 


I have a seemingly simple problem here, but somehow can't figure out a

I compute a Plot of a Differential Equation, with variable x-ranges,
and want to show the graphic with a VectorFieldPlot as background.

Unfortunately, within Manipulate, the static VectorFieldPlot and the
whole Differential Equation are reevaluated anytime I move the slide bar.
This makes the whole movie very very slow. Is there a way to
"tell" Show that the VectorFieldPlot is just a background and doesn't need
to be reevaluated every time? I tried Dynamic Settings, and Background
but nothing really works:

Below a code snippet to give you a better idea of what I mean:

-- Code (copypaste-able directly into M6 nb)

pl1 = VectorFieldPlot[{1, Cos[x]}, {x, -5, 5}, {y, -5, 5}];

pl2 = Plot[Cos[x], {x, -5, -5 + k},
PlotRange -> {-5, 5},
PerformanceGoal -> "Speed"
Show[pl1, pl2, PlotRange -> {-5, 5}
{{k, 1, "k"}, 1, 10}, TrackedSymbols :> {k}]

-- End of Code

As you can see, this simple example with Cos(x) is already
quite slow...when using more graphics options (eg colors)
and more complicated functions, the movie just becomes
much too slow, especially when considering that the actual
effort isn't that big. I even tried to pre-calculate an array of
pictures and just print them out in the Manipulate eg Array[[k]],
but even this is slow.

Does anyone have an idea how to speed this up? Thanks in advance!


Michael Hsieh

  • Prev by Date: Re: Mathematica 7 is now available
  • Next by Date: Re: Dynamic Show in Manipulate
  • Previous by thread: Dynamic Show in Manipulate
  • Next by thread: Re: Dynamic Show in Manipulate