#12035: `list_plot` should accept lists of complex numbers
---------------------------+------------------------------------------------
   Reporter:  ddrake       |          Owner:  jason, was        
       Type:  enhancement  |         Status:  needs_review      
   Priority:  major        |      Milestone:  sage-4.8          
  Component:  graphics     |       Keywords:  list_plot, complex
Work_issues:               |       Upstream:  N/A               
   Reviewer:               |         Author:                    
     Merged:               |   Dependencies:                    
---------------------------+------------------------------------------------
Changes (by ddrake):

  * status:  new => needs_review


Old description:

> If I do
> {{{
> list_plot([1+I, 2+I, 4-I])
> }}}
> it's totally obvious what I want. We should make `list_plot` accept lists
> of complex numbers.
>
> The core problem here is in `xydata_from_point_list` in `plot.py`.
> There's some complex number support there (see #8082) but not what I
> would like.

New description:

 If I do
 {{{
 list_plot([1+I, 2+I, 4-I])
 }}}
 it's totally obvious what I want. We should make `list_plot` accept lists
 of complex numbers.

--

Comment:

 Patch up, please review. I improved the docstring for `list_plot`. I would
 like feedback on my method for detecting complex numbers. Right now, I do:
 {{{
 from sage.rings.complex_field import ComplexField
 CC = ComplexField()
 from sage.rings.complex_number import is_ComplexNumber
 if any(abs(CC(z).imag()) > 0 or is_ComplexNumber(z) for z in data):
     data = [(z.real(), z.imag()) for z in data]
 }}}
 But I have a couple concerns:

 * do we need to worry about numerical noise? Will testing for
 `abs(imaginary part) > 0` suffice?

 * are `ComplexField()` and `is_ComplexNumber` the right functions to use
 here?

 Also, we *do* need to figure this out in `list_plot`, and not in
 `xydata_from_point_list`, because `list_plot` needs to decide whether to
 turn the data into tuples of real and imaginary parts, or do
 `zip(range(len(data)), data)`.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12035#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en.

Reply via email to