Ticket #5259 (closed defect: fixed)
[with patch, positive review] invalid array elements sent to matplotlib quiver, causing blank plot
| Reported by: | jason | Owned by: | jason |
|---|---|---|---|
| Priority: | major | Milestone: | sage-3.3 |
| Component: | graphics | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
A student noticed that sometimes, when a function evaluation gave Inf or NaN, the vector field plot was blank. Discussing this on the matplotlib-users list revealed that we ought to mask our arrays before sending them to the matplotlib quiver function. This patch corrects this, so that the plot:
plot_vector_field( (-x/sqrt(x^2+y^2), -y/sqrt(x^2+y^2)), (x, -10, 10), (y, -10, 10))
now plots (before it was a blank plot, now it just skips the problematic vectors).
Attachments
Change History
comment:1 Changed 4 years ago by jason
- Summary changed from invalid array elements sent to matplotlib quiver, causing blank plot to [with patch, needs review] invalid array elements sent to matplotlib quiver, causing blank plot
comment:2 Changed 4 years ago by jason
- Owner changed from was to jason
- Status changed from new to assigned
To test this, you might try the following plots before and after the patch:
sage: var('x,y')
sage: plot_vector_field( (-x/sqrt(x^2+y^2), -y/sqrt(x^2+y^2)), (x, -10, 10), (y, -10, 10))
sage: plot_vector_field( (-x/sqrt(x+y), -y/sqrt(x+y)), (x, -10, 10), (y, -10, 10))
comment:3 Changed 4 years ago by jason
For the matplotlib-users discussion, see the messages with subject "quiver and Inf values" here: http://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-users&max_rows=25&style=ultimate&viewmonth=200902&viewday=13
comment:4 Changed 4 years ago by jason
updated patch corrects the silly mistake in the doctest (I didn't account for the output of var('x,y')). Now doctests pass in plot/*.py.

