I cannot get the pyplot colorbar to cooperate in a scatter where I specifically set facecolors=None and only want to display the edge of the scattered circles. Could someone please point me in the right direction? Thanks.
This works fine:
# Solid circles - colorbar shows
plt.scatter(x, y, c=z, s=15, lw=0.3, cmap='viridis')
plt.colorbar()
plt.show()
... but this doesnt:
c = plt.cm.viridis(z)
plt.scatter(x, y, facecolors = 'none', edgecolors = c, s = 15, lw = 0.3)
plt.colorbar()
plt.show()
Traceback (most recent call last): File "/API/ML_GenerateFeatures.py", line 221, in
<module> va.scatter_color(df.OIR, df.fwd_delta_mid, df.spread)
File "/API/ML_GenerateFeatures.py", line 184, in scatter_color plt.colorbar()
File "C:\Python27\Lib\site-packages\matplotlib\pyplot.py", line 2180, in colorbar ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
File "C:\Python27\Lib\site-packages\matplotlib\figure.py", line 1844, in colorbar cb = cbar.colorbar_factory(cax, mappable, **kw)
File "C:\Python27\Lib\site-packages\matplotlib\colorbar.py", line 1365, in colorbar_factory cb = Colorbar(cax, mappable, **kwargs)
File "C:\Python27\Lib\site-packages\matplotlib\colorbar.py", line 918, in __init__ mappable.autoscale_None()
File "C:\Python27\Lib\site-packages\matplotlib\cm.py", line 348, in autoscale_None
raise TypeError('You must first set_array for mappable')
TypeError: You must first set_array for mappable