[yt-dev] Issue #745: Can't pl.plot(YTArray, YTArray) (yt_analysis/yt)

Sam Skillman issues-reply at bitbucket.org
Mon Dec 9 09:35:30 PST 2013


New issue 745: Can't pl.plot(YTArray, YTArray)
https://bitbucket.org/yt_analysis/yt/issue/745/cant-plplot-ytarray-ytarray

Sam Skillman:


```
#!python

from yt.mods import *
import matplotlib.pyplot as plt
a = YTArray([1.0,2.0])
plt.plot(a, a)

```

produces:


```
#!python

(yt-x86_64)360Mpc/1024L0:python test_plot.py                                                                                                                                                                                           
Traceback (most recent call last):                                                                                                                                                                                                       File "test_plot.py", line 6, in <module>                                                                                                                                                                                             
    plt.plot(a, a)                                                                                                                                                                                                                     
  File "/u/ki/skillman/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/pyplot.py", line 2987, in plot                                                                                         
    ret = ax.plot(*args, **kwargs)                                                                                                                                                                                                     
  File "/u/ki/skillman/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/axes.py", line 4137, in plot                                                                                           
    for line in self._get_lines(*args, **kwargs):                                                                                                                                                                                      
  File "/u/ki/skillman/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/axes.py", line 317, in _grab_next_args                                                                                 
    for seg in self._plot_args(remaining, kwargs):                                                                                                                                                                                     
  File "/u/ki/skillman/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/axes.py", line 276, in _plot_args                                                                                      
    linestyle, marker, color = _process_plot_format(tup[-1])                                                                                                                                                                           
  File "/u/ki/skillman/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/axes.py", line 80, in _process_plot_format                                                                             
    color = mcolors.colorConverter.to_rgb(fmt)                                                                                                                                                                                         
  File "/u/ki/skillman/yt-x86_64/lib/python2.7/site-packages/matplotlib-1.3.0-py2.7-linux-x86_64.egg/matplotlib/colors.py", line 291, in to_rgb                                                                                        
    argl = arg.lower()                                                                                                                                                                                                                 
AttributeError: 'YTArray' object has no attribute 'lower' 
```

Using .to_ndarray() on a in the plotting call works as expected.  pl.plot(a) also works, so I think this must be something about mpl interpreting the second ytarray as a different arg/kwarg.

Responsible: ngoldbaum



More information about the yt-dev mailing list