Re: How to combine Dynamic graphics in Show?
- To: mathgroup at smc.vnet.net
- Subject: [mg105529] Re: [mg105506] How to combine Dynamic graphics in Show?
- From: "David Park" <djmpark at comcast.net>
- Date: Sun, 6 Dec 2009 01:33:38 -0500 (EST)
- References: <18360202.1260013525589.JavaMail.root@n11>
Nasser,
This is easy with Presentations and custom dynamics. I did change the
ListPlot to something that would be more overlapping with the Cos plot. I
calculate the contents of the two plots outside of the DynamicModule just to
show they are not being dynamically updated. Only the PlotRange is
dynamically updated.
Needs["Presentations`Master`"]
listdraw = ListDraw[Table[{x, x}, {x, -3, 3, .5}]];
cosdraw = Draw[Cos[x], {x, -\[Pi], \[Pi]}];
DynamicModule[
{maxy = 1},
Panel[
Row[
{VerticalSlider[Dynamic[maxy], {0.1, 4},
Appearance -> "LeftArrow"],
Draw2D[
{AbsolutePointSize[4],
listdraw,
cosdraw},
AspectRatio -> 1,
Frame -> True,
PlotRange -> Dynamic@{{-\[Pi], \[Pi]}, {-maxy, maxy}},
ImageSize -> {300, 300},
ImagePadding -> {{30, 10}, {30, 10}}](* Draw2D *)
}](* Row *),
Style["Nasser's Custom Dynamic II", 16](* Panel *),
ImageSize -> {380, 330}]
]
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
From: Nasser M. Abbasi [mailto:nma at 12000.org]
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