[Date Index]
[Thread Index]
[Author Index]
RE: Dynamic Show in Manipulate
*To*: mathgroup at smc.vnet.net
*Subject*: [mg94063] RE: [mg94041] Dynamic Show in Manipulate
*From*: "David Park" <djmpark at comcast.net>
*Date*: Thu, 4 Dec 2008 07:12:51 -0500 (EST)
*References*: <3853415.1228302997655.JavaMail.root@m02>
Michael,
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.
Needs["Presentations`Master`"]
background=VectorPlot[{1,Cos[x]},{x,-5,5},{y,-5,5}]//DrawGraphics;
Module[
{k = 1},
panelpage[
{phrase["k: ", Slider[Dynamic[k], {1, 10}], Spacer[5],
InputField[Dynamic[k], FieldSize -> {4, 1.2}]],
Draw2D[
{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 comcast.net
http://home.comcast.net/~djmpark
From: Michael Hsieh [mailto:JiaYow at gmail.com]
Hello!
I have a seemingly simple problem here, but somehow can't figure out a
solution:
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
Settings,
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)
Needs["VectorFieldPlots`"]
pl1 = VectorFieldPlot[{1, Cos[x]}, {x, -5, 5}, {y, -5, 5}];
Manipulate[
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!
Regards
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**
| |