Closed
Description
python3.5.1
matplotlib 1.5.1
jupyter 4.0.6
matplotlib.pyplot cannot render figures with new colormaps in discretized mode ('viridis' and friends).
with 'jet' and friends exception is not raised
How to reproduce:
import matplotlib.pyplot as plt
import numpy as np
a = np.random.randn(20,20)
cmap = plt.get_cmap('viridis',20)
plt.pcolormesh(a,cmap=cmap)
raises:
<matplotlib.collections.QuadMesh at 0x11a767198>
In [6]: Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 368, in to_rgba
'length of rgba sequence should be either 3 or 4')
ValueError: length of rgba sequence should be either 3 or 4
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 399, in to_rgba_array
return np.array([self.to_rgba(c, alpha)], dtype=np.float)
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 376, in to_rgba
'to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))
ValueError: to_rgba: Invalid rgba arg "['viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis', 'viridis']"
length of rgba sequence should be either 3 or 4
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 306, in to_rgb
fl = float(argl)
ValueError: could not convert string to float: 'viridis'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 370, in to_rgba
r, g, b = self.to_rgb(arg)
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 328, in to_rgb
'to_rgb: Invalid rgb arg "%s"\n%s' % (str(arg), exc))
ValueError: to_rgb: Invalid rgb arg "viridis"
could not convert string to float: 'viridis'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__.py", line 1549, in __call__
return self.func(*args)
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__.py", line 596, in callit
func(*args)
File "/usr/local/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 373, in idle_draw
self.draw()
File "/usr/local/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 354, in draw
FigureCanvasAgg.draw(self)
File "/usr/local/lib/python3.5/site-packages/matplotlib/backends/backend_agg.py", line 474, in draw
self.figure.draw(self.renderer)
File "/usr/local/lib/python3.5/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/matplotlib/figure.py", line 1159, in draw
func(*args)
File "/usr/local/lib/python3.5/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 2324, in draw
a.draw(renderer)
File "/usr/local/lib/python3.5/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/matplotlib/collections.py", line 1847, in draw
self.update_scalarmappable()
File "/usr/local/lib/python3.5/site-packages/matplotlib/collections.py", line 713, in update_scalarmappable
self._facecolors = self.to_rgba(self._A, self._alpha)
File "/usr/local/lib/python3.5/site-packages/matplotlib/cm.py", line 262, in to_rgba
x = self.cmap(x, alpha=alpha, bytes=bytes)
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 550, in __call__
self._init()
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 845, in _init
rgba = colorConverter.to_rgba_array(self.colors)
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 422, in to_rgba_array
result[i] = self.to_rgba(cc, alpha)
File "/usr/local/lib/python3.5/site-packages/matplotlib/colors.py", line 376, in to_rgba
'to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))
ValueError: to_rgba: Invalid rgba arg "viridis"
to_rgb: Invalid rgb arg "viridis"
could not convert string to float: 'viridis'