[yt-dev] Issue #572: Plot window plots of arrays that contain data filled with zeros will sometimes fail. (yt_analysis/yt)

Nathan Goldbaum issues-reply at bitbucket.org
Mon May 20 18:09:11 PDT 2013


New issue 572: Plot window plots of arrays that contain data filled with zeros will sometimes fail.
https://bitbucket.org/yt_analysis/yt/issue/572/plot-window-plots-of-arrays-that-contain

Nathan Goldbaum:

This multispecies enzo dataset is initialized to contain only ionized hydrogen, so the `HI_Density` field is zero everywhere.  Since this field is set to have a logarithmic colorbar by default, if I try to plot the field, the plotting code crashes:


```
#!python

from yt.mods import *
pf = load('DD0000/DD0000')
slc = SlicePlot(pf, 0, 'HI_Density')
```


```
#!python

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    slc = SlicePlot(pf,0,'HI_Density')
  File "/Users/goldbaum/Documents/yt-hg/yt/visualization/plot_window.py", line 1222, in __init__
    PWViewerMPL.__init__(self, slc, bounds, origin=origin, fontsize=fontsize)
  File "/Users/goldbaum/Documents/yt-hg/yt/visualization/plot_window.py", line 781, in __init__
    PWViewer.__init__(self, *args, **kwargs)
  File "/Users/goldbaum/Documents/yt-hg/yt/visualization/plot_window.py", line 605, in __init__
    if setup: self._setup_plots()
  File "/Users/goldbaum/Documents/yt-hg/yt/visualization/plot_window.py", line 890, in _setup_plots
    self.plots[f].image, cax = self.plots[f].cax)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1394, in colorbar
    cb = cbar.colorbar_factory(cax, mappable, **kw)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 1173, in colorbar_factory
    cb = Colorbar(cax, mappable, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 854, in __init__
    ColorbarBase.__init__(self, ax, **kw)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 298, in __init__
    self.draw_all()
  File "/usr/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 319, in draw_all
    self._process_values()
  File "/usr/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 632, in _process_values
    b = self.norm.inverse(self._uniform_y(self.cmap.N+1))
  File "/usr/local/lib/python2.7/site-packages/matplotlib/colors.py", line 982, in inverse
    return vmin * ma.power((vmax / vmin), val)
  File "/usr/local/lib/python2.7/site-packages/numpy/ma/core.py", line 3648, in __mul__
    return multiply(self, other)
  File "/usr/local/lib/python2.7/site-packages/numpy/ma/core.py", line 941, in __call__
    if m:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```

This could be fixed by switching to a linear colorbar inline.

Responsible: ngoldbaum



More information about the yt-dev mailing list