Sage: Ticket #10775: streamline plots
https://trac.sagemath.org/ticket/10775
<p>
Recently there was a thread on the matplotlib list where someone posted matplotlib code for a streamline plot. It looks very nice. If the code doesn't get included in matplotlib, we could still ask about including it in Sage to do streamline plots.
</p>
<p>
Mailing list message: <a class="ext-link" href="http://permalink.gmane.org/gmane.comp.python.matplotlib.general/26362"><span class="icon"></span>http://permalink.gmane.org/gmane.comp.python.matplotlib.general/26362</a>
</p>
<p>
Mailing list thread: <a class="ext-link" href="http://comments.gmane.org/gmane.comp.python.matplotlib.general/26354"><span class="icon"></span>http://comments.gmane.org/gmane.comp.python.matplotlib.general/26354</a>
</p>
<p>
Example code: <a class="ext-link" href="http://web.mit.edu/speth/Public/streamlines.py"><span class="icon"></span>http://web.mit.edu/speth/Public/streamlines.py</a>
</p>
<p>
Example plot: <a class="ext-link" href="http://web.mit.edu/speth/Public/streamlines.png"><span class="icon"></span>http://web.mit.edu/speth/Public/streamlines.png</a>
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/10775
Trac 1.1.6jasonMon, 14 Feb 2011 12:27:11 GMT
https://trac.sagemath.org/ticket/10775#comment:1
https://trac.sagemath.org/ticket/10775#comment:1
<p>
And here is another file from the same message with some fantastically nice plots:
</p>
<p>
Code: <a class="ext-link" href="http://www.atm.damtp.cam.ac.uk/people/tjf37/streamplot.py"><span class="icon"></span>http://www.atm.damtp.cam.ac.uk/people/tjf37/streamplot.py</a>
</p>
<p>
Result: <a class="ext-link" href="http://www.atm.damtp.cam.ac.uk/people/tjf37/streamlines1.png"><span class="icon"></span>http://www.atm.damtp.cam.ac.uk/people/tjf37/streamlines1.png</a>
</p>
<p>
Result 2: <a class="ext-link" href="http://www.atm.damtp.cam.ac.uk/people/tjf37/streamlines2.png"><span class="icon"></span>http://www.atm.damtp.cam.ac.uk/people/tjf37/streamlines2.png</a>
</p>
TicketjasonMon, 14 Feb 2011 12:28:34 GMTattachment set
https://trac.sagemath.org/ticket/10775
https://trac.sagemath.org/ticket/10775
<ul>
<li><strong>attachment</strong>
set to <em>streamlines.py</em>
</li>
</ul>
TicketjasonMon, 14 Feb 2011 12:28:41 GMTattachment set
https://trac.sagemath.org/ticket/10775
https://trac.sagemath.org/ticket/10775
<ul>
<li><strong>attachment</strong>
set to <em>streamplot.py</em>
</li>
</ul>
TicketjasonMon, 14 Feb 2011 12:29:10 GMT
https://trac.sagemath.org/ticket/10775#comment:2
https://trac.sagemath.org/ticket/10775#comment:2
<p>
I've attached both code files so that we have them even if the above links go down for whatever reason.
</p>
TicketjasonTue, 27 Sep 2011 20:45:04 GMT
https://trac.sagemath.org/ticket/10775#comment:3
https://trac.sagemath.org/ticket/10775#comment:3
<p>
See <a class="ext-link" href="http://sagenb.org/home/pub/3237/"><span class="icon"></span>http://sagenb.org/home/pub/3237/</a> for a short example and rough Sage code (posted at <a class="ext-link" href="http://sage.math.washington.edu/home/jason/sage-field-plots/"><span class="icon"></span>http://sage.math.washington.edu/home/jason/sage-field-plots/</a>)
</p>
TicketkcrismanMon, 25 Jun 2012 19:25:15 GMTupstream changed
https://trac.sagemath.org/ticket/10775#comment:4
https://trac.sagemath.org/ticket/10775#comment:4
<ul>
<li><strong>upstream</strong>
changed from <em>N/A</em> to <em>Fixed upstream, but not in a stable release.</em>
</li>
</ul>
<p>
Yo, this is now in mpl!
</p>
<ul><li><a class="ext-link" href="https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/streamplot.py"><span class="icon"></span>the file</a>
</li><li><a class="ext-link" href="https://github.com/matplotlib/matplotlib/commit/687af189381b46e40a6b25b4aafa4e208962c914"><span class="icon"></span>the commit</a>
</li></ul><p>
I'm not sure how to figure out which release it's in, if it's in a release yet. It looks like it will probably be in 1.1.1, as 1.1.0 has been out for longer than this was in.
</p>
TicketjasonMon, 25 Jun 2012 20:59:54 GMT
https://trac.sagemath.org/ticket/10775#comment:5
https://trac.sagemath.org/ticket/10775#comment:5
<p>
See also <a class="ext-link" href="http://sage.cs.drake.edu/home/pub/60/"><span class="icon"></span>http://sage.cs.drake.edu/home/pub/60/</a> for another example.
</p>
TicketjasonTue, 02 Oct 2012 13:11:39 GMTattachment set
https://trac.sagemath.org/ticket/10775
https://trac.sagemath.org/ticket/10775
<ul>
<li><strong>attachment</strong>
set to <em>DE Solutions (1).sws</em>
</li>
</ul>
TicketjasonTue, 02 Oct 2012 13:12:06 GMT
https://trac.sagemath.org/ticket/10775#comment:6
https://trac.sagemath.org/ticket/10775#comment:6
<p>
I attached the example I pointed out in the sage.cs.drake.edu server.
</p>
TicketkcrismanSun, 03 Mar 2013 01:01:27 GMT
https://trac.sagemath.org/ticket/10775#comment:7
https://trac.sagemath.org/ticket/10775#comment:7
<p>
<a class="closed ticket" href="https://trac.sagemath.org/ticket/13693" title="task: Upgrade matplotlib to 1.2.1 (closed: fixed)">#13693</a> is for the appropriate mpl upgrade for this.
</p>
TicketjdemeyerTue, 13 Aug 2013 15:35:53 GMTmilestone changed
https://trac.sagemath.org/ticket/10775#comment:8
https://trac.sagemath.org/ticket/10775#comment:8
<ul>
<li><strong>milestone</strong>
changed from <em>sage-5.11</em> to <em>sage-5.12</em>
</li>
</ul>
Ticketvbraun_spamThu, 30 Jan 2014 21:20:52 GMTmilestone changed
https://trac.sagemath.org/ticket/10775#comment:9
https://trac.sagemath.org/ticket/10775#comment:9
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.1</em> to <em>sage-6.2</em>
</li>
</ul>
Ticketvbraun_spamTue, 06 May 2014 15:20:58 GMTmilestone changed
https://trac.sagemath.org/ticket/10775#comment:10
https://trac.sagemath.org/ticket/10775#comment:10
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.2</em> to <em>sage-6.3</em>
</li>
</ul>
Ticketvbraun_spamSun, 10 Aug 2014 16:51:03 GMTmilestone changed
https://trac.sagemath.org/ticket/10775#comment:11
https://trac.sagemath.org/ticket/10775#comment:11
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.3</em> to <em>sage-6.4</em>
</li>
</ul>
TicketkcrismanThu, 30 Oct 2014 18:32:12 GMT
https://trac.sagemath.org/ticket/10775#comment:12
https://trac.sagemath.org/ticket/10775#comment:12
<p>
Here are some <a class="ext-link" href="http://matplotlib.org/examples/images_contours_and_fields/streamplot_demo_features.html"><span class="icon"></span>upstream examples</a>.
</p>
<hr />
<p>
Here is another example from somewhere in this discussion, allowing phase plots. Not directly related but looks nice with such things.
</p>
<pre class="wiki"># based on code from oddrobot, http://sagenb.org/home/pub/1532/
from sage.calculus.desolvers import desolve_system_rk4
x,y,t=var('x y t')
class DESolution:
def __init__(self,system,time_range,initial,stepsize=0.05):
self.tvar=time_range[0]
self._times=srange(time_range[1],time_range[2],stepsize)
self.vars=[v for v,_ in initial]
self.dim=len(self.vars)
self._soln=desolve_odeint(system, ics=[v for _,v in initial], times=self._times, dvars=self.vars, ivar=self.tvar)
def phase_plot(self,vars=None,color='blue',**kwargs):
# find which indices the specified variables are
if vars is not None:
vars_index=[self.vars.index(v) for v in vars]
elif self.dim<=3:
vars_index=range(self.dim)
else:
vars_index=range(2)
p=line(self._soln[:,vars_index],color=color,**kwargs)
# add an arrow head showing which way we are going around the phase line
half=int(self._soln.shape[0]/2)
p+=arrow(self._soln[half,vars_index], self._soln[half+1,vars_index],color=color)
if len(vars_index)==2:
p.axes_labels([str(self.vars[v]) for v in vars_index])
return p
def coordinates(self,colors=None,**kwargs):
if colors is None:
colors=rainbow(len(self.vars))
p=Graphics()
p+=sum(line(zip(self._times,self._soln[:,i]), color=colors[i], legend_label=str(self.vars[i]),**kwargs) for i in range(self.dim))
return p
</pre>
TickettscrimMon, 12 Sep 2016 16:46:33 GMTcc, milestone, upstream changed
https://trac.sagemath.org/ticket/10775#comment:13
https://trac.sagemath.org/ticket/10775#comment:13
<ul>
<li><strong>cc</strong>
<em>alauve</em> <em>jakobkroeker</em> <em>paulmasson</em> <em>jhonrubia6</em> added
</li>
<li><strong>milestone</strong>
changed from <em>sage-6.4</em> to <em>sage-7.4</em>
</li>
<li><strong>upstream</strong>
changed from <em>Fixed upstream, but not in a stable release.</em> to <em>Completely fixed; Fix reported upstream</em>
</li>
</ul>
<p>
I was hoping we could resurrect this ticket as I am teaching a class on ODE's this semester and would like to plot streamlines on top of the slope fields. Does someone have some time to work on this? Alas, I don't know how much time I might have to do so.
</p>
<p>
So streamlines are included in matplotlib: <a class="ext-link" href="http://matplotlib.org/examples/images_contours_and_fields/streamplot_demo_features.html"><span class="icon"></span>http://matplotlib.org/examples/images_contours_and_fields/streamplot_demo_features.html</a>
</p>
<p>
There is also another plot package I came across that is open-source python that does streamlines: <a class="ext-link" href="https://plot.ly/python/streamline-plots/"><span class="icon"></span>https://plot.ly/python/streamline-plots/</a>
</p>
TicketpaulmassonTue, 13 Sep 2016 01:37:17 GMT
https://trac.sagemath.org/ticket/10775#comment:14
https://trac.sagemath.org/ticket/10775#comment:14
<p>
Since I spent too much time today reading graphics code, I can take a crack at this. It looks like a new class is needed, modeled on <code>PlotField</code> but calling the <code>pyplot</code> method <code>streamplot</code> instead of <code>quiver</code>. It shouldn't be too difficult but won't happen overnight.
</p>
<p>
Travis, if you see a way to avoid a new class, then let me know before I dive in tomorrow.
</p>
TicketpaulmassonTue, 13 Sep 2016 01:58:04 GMT
https://trac.sagemath.org/ticket/10775#comment:15
https://trac.sagemath.org/ticket/10775#comment:15
<p>
To clarify: by new class I mean an individual file like <code>scatter_plot.py</code>, which calls the <code>pyplot</code> method <code>scatter</code>.
</p>
TicketkcrismanTue, 13 Sep 2016 13:24:34 GMT
https://trac.sagemath.org/ticket/10775#comment:16
https://trac.sagemath.org/ticket/10775#comment:16
<p>
Yes, this is exactly how you should do it. You could even keep it in the same module as the vector field plots, you can see that e.g. contour and density plots are in the same file.
</p>
TickettscrimTue, 13 Sep 2016 13:31:53 GMT
https://trac.sagemath.org/ticket/10775#comment:17
https://trac.sagemath.org/ticket/10775#comment:17
<p>
Thank you for taking point on this Paul!
</p>
<p>
I agree with Karl-Dieter, you should definitely create a new class. However, contour and density plots are in separate files. Although, I have no preference whether or not you put in a separate file; it fits very well with <code>plot_field.py</code>.
</p>
TicketpaulmassonWed, 14 Sep 2016 21:32:29 GMTbranch set
https://trac.sagemath.org/ticket/10775#comment:18
https://trac.sagemath.org/ticket/10775#comment:18
<ul>
<li><strong>branch</strong>
set to <em>u/paulmasson/10775</em>
</li>
</ul>
TicketpaulmassonWed, 14 Sep 2016 21:41:18 GMTstatus changed; commit, author set
https://trac.sagemath.org/ticket/10775#comment:19
https://trac.sagemath.org/ticket/10775#comment:19
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>commit</strong>
set to <em>9576ba7abe47606fdf7667ea88e4bf8cf6dbefad</em>
</li>
<li><strong>author</strong>
set to <em>Paul Masson</em>
</li>
</ul>
<p>
This was surprisingly easy to get working! I copied over <code>plot_field.py</code> and left variable names the same for consistency. Then it was a matter of rearranging how the data arrays were assembled and changing the <code>pyplot</code> function name.
</p>
<p>
Doctests and useful examples have been updated. I left the <code>_allowed_options</code> untouched because they might be relevant.
</p>
<hr />
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=852c719b9707ee32622b6dbe3c0450d3e5f7fb49"><span class="icon"></span>852c719</a></td><td><code>Initial commit</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=e6094a3dc36480687265c2d7ea3c9db1fc5ab3cf"><span class="icon"></span>e6094a3</a></td><td><code>Initial working commit</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=188b3c75e50eece12cb3491bf8066abadf85c85c"><span class="icon"></span>188b3c7</a></td><td><code>Update doctests</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=4c2ff907b1fe8bcb4ead3874a4a5b76e3ab01f05"><span class="icon"></span>4c2ff90</a></td><td><code>Add streamline_plot</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=9576ba7abe47606fdf7667ea88e4bf8cf6dbefad"><span class="icon"></span>9576ba7</a></td><td><code>Update documentation</code>
</td></tr></table>
TickettscrimThu, 15 Sep 2016 04:06:10 GMT
https://trac.sagemath.org/ticket/10775#comment:20
https://trac.sagemath.org/ticket/10775#comment:20
<p>
Sorry to ask for a bit more. Could we add a way to input an initial point, allow input as a single function to treat it as a slope field, and an option to display the vector/slope field? If this is too much trouble, I am okay with positive reviewing this ticket as-is.
</p>
TicketpaulmassonThu, 15 Sep 2016 23:43:03 GMT
https://trac.sagemath.org/ticket/10775#comment:21
https://trac.sagemath.org/ticket/10775#comment:21
<p>
Travis, if by "initial point" you mean initial conditions, aren't those just part of the function arguments given to the plot? What more do you intend with this feature?
</p>
<p>
The idea of a convenience function that switches between streamline and vector/slope plots is interesting, but shouldn't be part of <code>streamline_plot</code> itself. That one should stand alone, partly because the <code>streamplot</code> function it uses behaves differently from the <code>quiver</code> function used by the others. Some of the examples from <code>plot_field.py</code> had to be left out of this new file because <code>streamplot</code> returned errors for them.
</p>
<p>
Would this convenience function be used regularly by others, or just you for one class? What's the rule of thumb for adding those sorts of features to Sage?
</p>
<p>
If you still want an additional convenience function added to this file, give me a name for it and its options.
</p>
TickettscrimThu, 15 Sep 2016 23:59:50 GMT
https://trac.sagemath.org/ticket/10775#comment:22
https://trac.sagemath.org/ticket/10775#comment:22
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/10775#comment:21" title="Comment 21">paulmasson</a>:
</p>
<blockquote class="citation">
<p>
Travis, if by "initial point" you mean initial conditions, aren't those just part of the function arguments given to the plot?
</p>
</blockquote>
<p>
Yes, but how I am reading the code, it looks like it does streamlines starting at each integer point.
</p>
<blockquote class="citation">
<p>
What more do you intend with this feature?
</p>
</blockquote>
<p>
Plot a solution for a given IVP.
</p>
<blockquote class="citation">
<p>
The idea of a convenience function that switches between streamline and vector/slope plots is interesting, but shouldn't be part of <code>streamline_plot</code> itself. That one should stand alone, partly because the <code>streamplot</code> function it uses behaves differently from the <code>quiver</code> function used by the others. Some of the examples from <code>plot_field.py</code> had to be left out of this new file because <code>streamplot</code> returned errors for them.
</p>
</blockquote>
<p>
If you look at the slope plot, it redirects to the vector plot with special options. We should be able to automate this by looking at the input, a tuple for a vector plot and otherwise consider it a slope plot.
</p>
<blockquote class="citation">
<p>
Would this convenience function be used regularly by others, or just you for one class? What's the rule of thumb for adding those sorts of features to Sage?
</p>
</blockquote>
<p>
I would be surprised if this did not get significant uptake in a variety of other classes. One of my first forays into Python was plotting a single streamline for the Lorenz attractor. However, there are a number of things in Sage that are likely only used by a few people, so the rule is it gets added if someone is willing to positively review it.
</p>
<blockquote class="citation">
<p>
If you still want an additional convenience function added to this file, give me a name for it and its options.
</p>
</blockquote>
<p>
Granted, I would eventually like a 3d version, but that can most certainly be a followup ticket.
</p>
<p>
I should have time next week to actually directly work on this (i.e. write code).
</p>
TicketgitThu, 22 Sep 2016 23:09:07 GMTcommit changed
https://trac.sagemath.org/ticket/10775#comment:23
https://trac.sagemath.org/ticket/10775#comment:23
<ul>
<li><strong>commit</strong>
changed from <em>9576ba7abe47606fdf7667ea88e4bf8cf6dbefad</em> to <em>9201066f0ce6d2aab310a875b00a2eeeb4ec75e3</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit/?id=77651dfd4f469cc5466471142842fb8f0dc73b62"><span class="icon"></span>77651df</a></td><td><code>Remove unused keyword arguments</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit/?id=9201066f0ce6d2aab310a875b00a2eeeb4ec75e3"><span class="icon"></span>9201066</a></td><td><code>Add density option</code>
</td></tr></table>
TicketpaulmassonThu, 22 Sep 2016 23:20:23 GMT
https://trac.sagemath.org/ticket/10775#comment:24
https://trac.sagemath.org/ticket/10775#comment:24
<p>
Travis, I went through the existing options, removed those that are not accepted by <code>streamplot</code> and added one that is, <code>density</code>. This value must be a single float or a pair of floats in a list, although I haven't added any validation for input values. It will at least allow you to see more streamlines and verify that they do not always start at integers.
</p>
<p>
There is another <code>streamplot</code> option I though might be interesting called <code>start_points</code>, but all it does is restrict streamlines to only those passing through an input list of points. You can test it by adding an option <code>start_points=[[0,.1],[0,-.1]]</code> or the like. Doesn't look too interesting to me.
</p>
TickettscrimFri, 23 Sep 2016 04:00:10 GMTcommit, branch changed; reviewer set
https://trac.sagemath.org/ticket/10775#comment:25
https://trac.sagemath.org/ticket/10775#comment:25
<ul>
<li><strong>commit</strong>
changed from <em>9201066f0ce6d2aab310a875b00a2eeeb4ec75e3</em> to <em>584486bf675c0c4b813ca2a75f745369f55f65a6</em>
</li>
<li><strong>branch</strong>
changed from <em>u/paulmasson/10775</em> to <em>u/tscrim/streamline_plot-10775</em>
</li>
<li><strong>reviewer</strong>
set to <em>Travis Scrimshaw</em>
</li>
</ul>
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/10775#comment:24" title="Comment 24">paulmasson</a>:
</p>
<blockquote class="citation">
<p>
Travis, I went through the existing options, removed those that are not accepted by <code>streamplot</code> and added one that is, <code>density</code>. This value must be a single float or a pair of floats in a list, although I haven't added any validation for input values. It will at least allow you to see more streamlines and verify that they do not always start at integers.
</p>
</blockquote>
<p>
I added some input checking, but <code>density</code> will still need to be documented.
</p>
<blockquote class="citation">
<p>
There is another <code>streamplot</code> option I though might be interesting called <code>start_points</code>, but all it does is restrict streamlines to only those passing through an input list of points. You can test it by adding an option <code>start_points=[[0,.1],[0,-.1]]</code> or the like. Doesn't look too interesting to me.
</p>
</blockquote>
<p>
It is useful for showing numerical solutions to initial value problems (IVPs) of (nonlinear) ODEs. Also useful for seeing how stable solutions are. Although it is very annoying that it can't plot start points that are too close together:
</p>
<pre class="wiki">sage: x,y = var('x,y')
sage: f = (x + y) / sqrt(x^2 + y^2)
sage: pts = [[-1., -2.+val/8] for val in range(10)]
sage: streamline_plot((cos(x), sin(x+y)), (x,-3,3), (y,-3,3), start_points=pts)
/home/travis/sage-build/local/lib/python2.7/site-packages/sage/repl/rich_output/display_manager.py:590: RichReprWarning: Exception in _rich_repr_ while displaying object:
RichReprWarning,
Graphics object consisting of 1 graphics primitive
</pre><p>
Although this is not something that would (nor should) block this getting a positive review.
</p>
<hr />
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=c443cc46e89bd1a3869cfb7ce93727f11939e536"><span class="icon"></span>c443cc4</a></td><td><code>Merge branch 'u/paulmasson/10775' of git://trac.sagemath.org/sage into u/paulmasson/10775</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=584486bf675c0c4b813ca2a75f745369f55f65a6"><span class="icon"></span>584486b</a></td><td><code>Adding start points option and slope field input.</code>
</td></tr></table>
TicketpaulmassonFri, 23 Sep 2016 21:25:33 GMTbranch changed
https://trac.sagemath.org/ticket/10775#comment:26
https://trac.sagemath.org/ticket/10775#comment:26
<ul>
<li><strong>branch</strong>
changed from <em>u/tscrim/streamline_plot-10775</em> to <em>u/paulmasson/streamline_plot-10775</em>
</li>
</ul>
TicketpaulmassonFri, 23 Sep 2016 21:41:56 GMTcommit changed
https://trac.sagemath.org/ticket/10775#comment:27
https://trac.sagemath.org/ticket/10775#comment:27
<ul>
<li><strong>commit</strong>
changed from <em>584486bf675c0c4b813ca2a75f745369f55f65a6</em> to <em>9f3a5c25cd924b53bb8c4cb58fe6bd992440e40a</em>
</li>
</ul>
<p>
Ah, so that's what you had in mind for the additions.
</p>
<p>
The documentation would not build without some fixes. Sphinx plots do not allow <code>^</code> for exponentiation, needs to be <code>**</code>, and variable declarations do not carry over between them. Documentation now builds.
</p>
<hr />
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=9f3a5c25cd924b53bb8c4cb58fe6bd992440e40a"><span class="icon"></span>9f3a5c2</a></td><td><code>Fix Sphinx plots</code>
</td></tr></table>
TicketpaulmassonFri, 23 Sep 2016 22:07:44 GMT
https://trac.sagemath.org/ticket/10775#comment:28
https://trac.sagemath.org/ticket/10775#comment:28
<p>
Don't know if you noticed, Travis, but in the example with <code>start_points</code> the streamlines come close to the start points but do not pass through them. I thought it might be because you didn't process the start points as in this example
</p>
<p>
<a class="ext-link" href="http://matplotlib.org/examples/images_contours_and_fields/streamplot_demo_start_points.html"><span class="icon"></span>http://matplotlib.org/examples/images_contours_and_fields/streamplot_demo_start_points.html</a>
</p>
<p>
but even with setting up a numpy array as indicated and transposing it, the streamlines still do not pass through the start points. In fact the resulting graph is exactly the same as not bothering to process the points, so apparently that isn't necessary.
</p>
<p>
Problem with <code>streamplot</code>? Thought you should know before any students ask what's going on.
</p>
TickettscrimFri, 23 Sep 2016 23:24:38 GMT
https://trac.sagemath.org/ticket/10775#comment:29
https://trac.sagemath.org/ticket/10775#comment:29
<p>
Thanks for fixing that Paul. I guess we should add a note and example about the behavior of <code>start_points</code>. Also, do you want me to document the <code>density</code> option?
</p>
<p>
Actually, I think I should not be normalizing the input when we want to consider it as a slope field, which makes sense when considering plotting the tangent lines. I believe it just adds a unnecessary computation that cancels when considering splitting <code>dy / dx</code> to <code>(dx, dy)</code>.
</p>
TicketgitSat, 24 Sep 2016 00:28:25 GMTcommit changed
https://trac.sagemath.org/ticket/10775#comment:30
https://trac.sagemath.org/ticket/10775#comment:30
<ul>
<li><strong>commit</strong>
changed from <em>9f3a5c25cd924b53bb8c4cb58fe6bd992440e40a</em> to <em>478b1e19adc03befdc57d983aea8a09fc6e3e4dd</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit/?id=78c53a01a55b27e736878f08c366a86e9eff0c64"><span class="icon"></span>78c53a0</a></td><td><code>Improve documentation and example</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit/?id=478b1e19adc03befdc57d983aea8a09fc6e3e4dd"><span class="icon"></span>478b1e1</a></td><td><code>Code block for start_points</code>
</td></tr></table>
TicketpaulmassonSat, 24 Sep 2016 00:32:20 GMT
https://trac.sagemath.org/ticket/10775#comment:31
https://trac.sagemath.org/ticket/10775#comment:31
<p>
Documentation for implemented plot options now included. I also updated your language for <code>start_points</code> using that from the matplotlib website and added the note.
</p>
<p>
I'm including a commented code block for the official way to handle <code>start_points</code> in the event it is useful later.
</p>
TickettscrimSat, 24 Sep 2016 04:26:46 GMT
https://trac.sagemath.org/ticket/10775#comment:32
https://trac.sagemath.org/ticket/10775#comment:32
<p>
I disagree with adding <code>start_points</code> to the <code>@options</code>, where if that is changed, it is perpetuated in all future plots, which is not what we want. I will revert this back when I make my next round of changes.
</p>
<p>
Does the "official way" for <code>start_points</code> make any difference?
</p>
TicketpaulmassonSat, 24 Sep 2016 19:45:43 GMT
https://trac.sagemath.org/ticket/10775#comment:33
https://trac.sagemath.org/ticket/10775#comment:33
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/10775#comment:32" title="Comment 32">tscrim</a>:
</p>
<blockquote class="citation">
<p>
Does the "official way" for <code>start_points</code> make any difference?
</p>
</blockquote>
<p>
Not that I can tell. <code>xpos_array</code> and <code>ypos_array</code> need to be explicit numpy arrays to avoid errors. The documentation says that <code>start_points</code> is also supposed to be a numpy array, so I added this block of commented code in case that is ever enforced, but you can remove it if you feel that is more appropriate.
</p>
TickettscrimTue, 27 Sep 2016 15:44:11 GMT
https://trac.sagemath.org/ticket/10775#comment:34
https://trac.sagemath.org/ticket/10775#comment:34
<p>
Let's use the official way. Also (not that it makes any real difference), you don't need to pop off the option:
</p>
<div class="wiki-code"><div class="code"><pre> <span class="k">if</span> <span class="s">'start_points'</span> <span class="ow">in</span> options<span class="p">:</span>
xstart_array<span class="p">,</span> ystart_array <span class="o">=</span> <span class="p">[],</span> <span class="p">[]</span>
<span class="k">for</span> point <span class="ow">in</span> options<span class="p">[</span><span class="s">'start_points'</span><span class="p">]:</span>
xstart_array<span class="o">.</span>append<span class="p">(</span>point<span class="p">[</span><span class="mi">0</span><span class="p">])</span>
ystart_array<span class="o">.</span>append<span class="p">(</span>point<span class="p">[</span><span class="mi">1</span><span class="p">])</span>
options<span class="p">[</span><span class="s">'start_points'</span><span class="p">]</span> <span class="o">=</span> numpy<span class="o">.</span>array<span class="p">([</span>xstart_array<span class="p">,</span> ystart_array<span class="p">])</span><span class="o">.</span>T
</pre></div></div>
TicketgitTue, 27 Sep 2016 21:33:37 GMTcommit changed
https://trac.sagemath.org/ticket/10775#comment:35
https://trac.sagemath.org/ticket/10775#comment:35
<ul>
<li><strong>commit</strong>
changed from <em>478b1e19adc03befdc57d983aea8a09fc6e3e4dd</em> to <em>79e879535dc2096ed3e15a77f4ff276253e72e44</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit/?id=79e879535dc2096ed3e15a77f4ff276253e72e44"><span class="icon"></span>79e8795</a></td><td><code>Update start_points handling</code>
</td></tr></table>
TickettscrimThu, 29 Sep 2016 02:10:16 GMTstatus changed
https://trac.sagemath.org/ticket/10775#comment:36
https://trac.sagemath.org/ticket/10775#comment:36
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
</ul>
<p>
Thank you for all your work on this.
</p>
TicketfbisseyMon, 03 Oct 2016 01:54:05 GMT
https://trac.sagemath.org/ticket/10775#comment:37
https://trac.sagemath.org/ticket/10775#comment:37
<p>
Not sure what Volker will find in his current run but I am failing to build the documentation in sage-on-gentoo
</p>
<pre class="wiki">[plotting ] /scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/build/lib/sage/plot/streamline_plot.py:docstring of sage.plot.streamline_plot.streamline_plot:35: WARNING: Exception occurred in plotting streamline_plot-1
[plotting ] from /scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/doc/en/reference/plotting/sage/plot/streamline_plot.rst:
[plotting ] Traceback (most recent call last):
[plotting ] File "/usr/lib64/python2.7/site-packages/matplotlib/sphinxext/plot_directive.py", line 517, in run_code
[plotting ] six.exec_(code, ns)
[plotting ] File "/usr/lib64/python2.7/site-packages/matplotlib/externals/six.py", line 672, in exec_
[plotting ] exec("""exec _code_ in _globs_, _locs_""")
[plotting ] File "<string>", line 1, in <module>
[plotting ] File "<string>", line 2, in <module>
[plotting ] File "/scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/build/lib/sage/misc/decorators.py", line 554, in wrapper
[plotting ] return func(*args, **options)
[plotting ] File "/scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/build/lib/sage/plot/streamline_plot.py", line 316, in streamline_plot
[plotting ] for point in options['start_points']:
[plotting ] TypeError: 'NoneType' object is not iterable
</pre><p>
I have this several times. I note that the bots have a similar problem in their logs.
</p>
TickettscrimMon, 03 Oct 2016 04:03:31 GMTstatus, commit, branch changed
https://trac.sagemath.org/ticket/10775#comment:38
https://trac.sagemath.org/ticket/10775#comment:38
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>needs_review</em>
</li>
<li><strong>commit</strong>
changed from <em>79e879535dc2096ed3e15a77f4ff276253e72e44</em> to <em>640cb6aad1a6b6380adabcb2c4d24d10eca3e718</em>
</li>
<li><strong>branch</strong>
changed from <em>u/paulmasson/streamline_plot-10775</em> to <em>u/tscrim/streamline_plot-10775</em>
</li>
</ul>
<p>
I had thought the first part of <a class="ticket" href="https://trac.sagemath.org/ticket/10775#comment:32" title="Comment 32">comment:32</a> was done by Paul. I removed <code>start_points</code> from the <code>@options</code> and did some little doc tweaking. Paul, can you make a quick check of my changes?
</p>
<hr />
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=1e2b2d06e1e9153dbf0fe420088796fbebdf976a"><span class="icon"></span>1e2b2d0</a></td><td><code>Merge branch 'u/paulmasson/10775' of git://trac.sagemath.org/sage into u/tscrim/streamline_plot-10775</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=fa8cda972a91c2b51ad743bd6318db8bd11b9bef"><span class="icon"></span>fa8cda9</a></td><td><code>Merge branch 'u/paulmasson/streamline_plot-10775' of git://trac.sagemath.org/sage into u/tscrim/streamline_plot-10775</code>
</td></tr><tr><td><a class="ext-link" href="https://git.sagemath.org/sage.git/commit?id=640cb6aad1a6b6380adabcb2c4d24d10eca3e718"><span class="icon"></span>640cb6a</a></td><td><code>Some last little touchups.</code>
</td></tr></table>
TicketpaulmassonMon, 03 Oct 2016 19:36:51 GMTstatus changed
https://trac.sagemath.org/ticket/10775#comment:39
https://trac.sagemath.org/ticket/10775#comment:39
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
</ul>
<p>
Documentation now builds. Setting back to positive review.
</p>
TicketvbraunFri, 21 Oct 2016 07:04:45 GMTstatus, branch changed; resolution set
https://trac.sagemath.org/ticket/10775#comment:40
https://trac.sagemath.org/ticket/10775#comment:40
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
<li><strong>branch</strong>
changed from <em>u/tscrim/streamline_plot-10775</em> to <em>640cb6aad1a6b6380adabcb2c4d24d10eca3e718</em>
</li>
</ul>
Ticket