scaleogram icon indicating copy to clipboard operation
scaleogram copied to clipboard

ValueError: Invalid RGBA argument: 0.2980392156862745

Open sunbc0120 opened this issue 5 years ago • 1 comments

running example from: https://github.com/alsauve/scaleogram/blob/master/doc/El-Nino-Dataset.ipynb

got:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-228-12f4d4229404> in <module>
     14 scales = np.logspace(1.2, 3.1, num=200, dtype=np.int32)
     15 #scales = np.arange(15,600, 4)
---> 16 ax = scg.cws(year, data, scales, figsize=(12,6), ylabel="Period [Years]", xlabel='Year', yscale='log')
     17 ticks = ax.set_yticks([2,4,8, 16,32])
     18 ticks = ax.set_yticklabels([2,4,8, 16,32])

~/anaconda3/envs/PdM/lib/python3.6/site-packages/scaleogram/cws.py in cws(time, signal, scales, wavelet, periods, spectrum, coi, coikw, yaxis, cscale, cmap, clim, cbar, cbarlabel, cbarkw, xlim, ylim, yscale, xlabel, ylabel, title, figsize, ax)
    262         plt.plot(xmesh, ymask)
    263         coikw = COI_DEFAULTS if coikw is None else coikw
--> 264         ax.fill_between(xmesh, yborder, ymask, **coikw )
    265 
    266     # color bar stuff

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1599     def inner(ax, *args, data=None, **kwargs):
   1600         if data is None:
-> 1601             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1602 
   1603         bound = new_sig.bind(ax, *args, **kwargs)

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/axes/_axes.py in fill_between(self, x, y1, y2, where, interpolate, step, **kwargs)
   5293             polys.append(X)
   5294 
-> 5295         collection = mcoll.PolyCollection(polys, **kwargs)
   5296 
   5297         # now update the datalim and autoscale

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/collections.py in __init__(self, verts, sizes, closed, **kwargs)
   1042         %(Collection)s
   1043         """
-> 1044         Collection.__init__(self, **kwargs)
   1045         self.set_sizes(sizes)
   1046         self.set_verts(verts, closed)

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
    160 
    161         self._path_effects = None
--> 162         self.update(kwargs)
    163         self._paths = None
    164 

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/artist.py in update(self, props)
    972 
    973         with cbook._setattr_cm(self, eventson=False):
--> 974             ret = [_update_property(self, k, v) for k, v in props.items()]
    975 
    976         if len(ret):

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/artist.py in <listcomp>(.0)
    972 
    973         with cbook._setattr_cm(self, eventson=False):
--> 974             ret = [_update_property(self, k, v) for k, v in props.items()]
    975 
    976         if len(ret):

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/artist.py in _update_property(self, k, v)
    969                     raise AttributeError('{!r} object has no property {!r}'
    970                                          .format(type(self).__name__, k))
--> 971                 return func(v)
    972 
    973         with cbook._setattr_cm(self, eventson=False):

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/collections.py in set_alpha(self, alpha)
    743         self.update_dict['array'] = True
    744         artist.Artist.set_alpha(self, alpha)
--> 745         self._set_facecolor(self._original_facecolor)
    746         self._set_edgecolor(self._original_edgecolor)
    747 

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/collections.py in _set_facecolor(self, c)
    659         except AttributeError:
    660             pass
--> 661         self._facecolors = mcolors.to_rgba_array(c, self._alpha)
    662         self.stale = True
    663 

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/colors.py in to_rgba_array(c, alpha)
    292     result = np.empty((len(c), 4), float)
    293     for i, cc in enumerate(c):
--> 294         result[i] = to_rgba(cc, alpha)
    295     return result
    296 

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
    175         rgba = None
    176     if rgba is None:  # Suppress exception chaining of cache lookup failure.
--> 177         rgba = _to_rgba_no_colorcycle(c, alpha)
    178         try:
    179             _colors_full_map.cache[c, alpha] = rgba

~/anaconda3/envs/PdM/lib/python3.6/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)
    238         # float)` and `np.array(...).astype(float)` all convert "0.5" to 0.5.
    239         # Test dimensionality to reject single floats.
--> 240         raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
    241     # Return a tuple to prevent the cached value from being modified.
    242     c = tuple(c.astype(float))

ValueError: Invalid RGBA argument: 0.2980392156862745

sunbc0120 avatar Sep 16 '19 08:09 sunbc0120

I cannot reproduce this issue, does it happens with newer python 3 versions?

The version of matplotlib used would be helpful, or maybe the now fixed iussue #4 may help.

alsauve avatar Oct 24 '21 15:10 alsauve