Prev: Finding how to do things by trial and error
Next: SetOptions[Plot, .Z..] vs using Plot[, .Z..] behaves differently when Z is Dynamics
From: Patrick Scheibe on 6 Dec 2009 01:39 Hi, you should really read some of the tutorials and look at sample code. In your example here you have to put the PlotRange in the Show ver = VerticalSlider[Dynamic[maxy], {0.1, 10}]; p0 = ListPlot[Range[10]]; p1 = Plot[Cos[x], {x, 0, 10}]; Row[{ver, Dynamic(a)Show[p1, p0, ImageSize -> 200, PlotRange -> {Automatic, {-maxy, maxy}}]}] is that what you tried? Cheers Patrick On Sat, 2009-12-05 at 06:35 -0500, 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(a)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(a)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 > >
From: John Fultz on 7 Dec 2009 02:00
Excerpting just a small bit here for clarification... On Sat, 5 Dec 2009 16:48:50 -0600, Nasser M. Abbasi wrote: > > > I went over help for Show again and again, and I do not see anywhere it > said that. And the examples I saw for Plot which uses a Dynamic was to > wrap a Plot with Dynamics, do I did that, i.e. to write > p=Dynamics(a)Plot[....]. The documentation says that "Show can be used with Graphics and Graphics3D." Show[{Plot[...], Dynamic[Plot[...]]}] fails for exactly the same reason that Show[[Plot[...], undefinedSymbol[Plot[...]]}] fails. Which fails for exactly the same reason that 2 + Dynamic[2] doesn''t return 4. Or that Factorial[Dynamic[5]] doesn't return 120. > But again, this I think should be documented in the help for show, may be > under possible issues, and also the error messages can be improved allot > to help users find where the problem is. If I want something from version > 8, it would be a more detailed and useful error messages. This will go a > long way to make programming in Mathematica a more pleasant endover. Perhaps the error message could be worded better, but I don't see how this is a "possible issue" for Show. Should we add "possible issues" examples for Plus and Factorial? The issue of understanding is with Dynamic, not with Show. Sincerely, John Fultz jfultz(a)wolfram.com User Interface Group Wolfram Research, Inc. |