Ticket #5259 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[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

trac_5259-mask-invalid-quiver-data.patch Download (1.5 KB) - added by jason 4 years ago.

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

Changed 4 years ago by jason

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.

comment:5 Changed 4 years ago by hivert

  • Summary changed from [with patch, needs review] invalid array elements sent to matplotlib quiver, causing blank plot to [with patch, positive review] invalid array elements sent to matplotlib quiver, causing blank plot

Everything look good !

comment:6 Changed 4 years ago by jason

Robert Nelson should be listed as the reporter of this bug.

comment:7 Changed 4 years ago by mabshoff

  • Status changed from assigned to closed
  • Resolution set to fixed

Merged in Sage 3.3.rc1.

Cheers,

Michael

Note: See TracTickets for help on using tickets.