Thanks for the response! I used some slightly different code; in case
anyone else deals
with the "wiggling graph" problem before the next SAGE is out, one snippet
that worked
for me follows:
*def f(x):
return x*sin(x^2)
v = []
# Define graph outside loop to avoid "wiggling graph" problem:
graph = plot(f, [-1, 3], thickness = 1, rgbcolor = (0,0,1))
# Now animate this graph:
for i in srange(10):
v.append(graph)
curve = animate(v)
curve.show()*
---
The graph was "immobile."
Dean
---
On Wed, Feb 20, 2008 at 3:41 PM, Jonathan Bober <[EMAIL PROTECTED]> wrote:
>
> The documentation for plot() says:
>
> The actual sample points are slightly randomized, so the above
> plots may look slightly different each time you draw them.
>
> I assume that this an easy way to get the behavior:
>
> Note that this function does NOT simply sample equally spaced
> points between xmin and xmax. Instead it computes equally spaced
> points and add small perturbations to them. This reduces the
> possibility of, e.g., sampling sin only at multiples of 2pi,
> which would yield a very misleading graph.
>
> So, perhaps this is a "feature". But it seems to me that the endpoints,
> at least, should be always included (if possible) when graphing a
> function, so maybe this is a bug. (Although it is nice to not include
> the endpoints when plotting something like sin(1/x).)
>
> But anyway, I think that you should be able to instead do:
>
> f = x*sin(x^2)
> v = []
> graph = plot(f, [-1, 3], thickness = 1, rgbcolor = (1, 0 ,0))
> for i in srange(50):
> v.append(graph)
> curve = animate(v)
> curve.show()
>
> On Wed, 2008-02-20 at 16:01 -0600, Jason Grout wrote:
> > dean moore wrote:
> > > I ran the code now living at < https://www.sagenb.org/home/pub/1691/>,
> > > but the function's graph
> > > "wiggles," most notably by the right endpoint. Tested, both Firefox &
> > > Internet Explorer. Same thing.
> > > Read through <
> > > http://www.sagemath.org/doc/html/ref/module-sage.plot.plot.html >, but
> > > found nothing.
> > >
> > > I am animating a graph, so it appears in all frames.
> > >
> > > I fiddled a good deal, but was left wondering, "Is it weirdness with
> > > SAGE, or my bad coding?" I beat
> > > the problem to a snippet:
> > >
> > > /f = x*sin(x^2)
> > > v = []
> > > for i in srange(50):
> > > graph = plot(f, [-1, 3], thickness = 1, rgbcolor = (1, 0 ,0),
> > > plot_points = 1000)
> > > v.append(graph)
> > > curve = animate(v)/
> > > /curve.show()
> > >
> >
> > Wow, this is a great animation. Sorry the plotting is so distracting at
> > the ends!
> >
> > To narrow down the issue, I executed the following after the code you
> gave:
> >
> > sage: endpoints = [v[i][0].xdata[-1] for i in srange(50)]
> > sage: max(endpoints) - min(endpoints)
> > 0.0039542538407206784
> >
> > This computes the endpoints for the x-values that are sampled to plot
> > the graph. That's quite a spread for having the exact same inputs,
> > which explains the noticable wiggling.
> >
> > So now the question is: why in the world do we have such different
> > endpoints?
> >
> > I might point out that the wiggling is not just at the endpoints of the
> > graph. The wiggling is throughout the graph; it's just really
> > noticeable at the endpoints.
> >
> > Jason
> >
> >
> >
> > >
> >
> >
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---