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.


Aha, looking at the help always helps!

plot? has the following:

        The actual sample points are slightly randomized, so the above
         plots may look slightly different each time you draw them.

Presumably this is to avoid things like sampling the same y-value on a 
periodic curve.  Unfortunately, it also seems to lead to this wiggling.

The problem in this case is that the randomness was applied to the 
beginning and ending points of the interval.  A patch is up at 
http://trac.sagemath.org/sage_trac/ticket/2236 which fixes this issue. 
The patch is just waiting for someone to referee it.  Are you 
comfortable doing that?

On another note, we still have wiggling in the middle of the graph. 
There ought to be options for turning off the randomness and for turning 
off the adaptive plotting for situations like your animation.  Creating 
these options is trac ticket #2237.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to