Skip to content

Error during plotting #1

@sbhakat

Description

@sbhakat

Hi,

During executing the following command

scatter(plot_feat[:,0],plot_feat[:,1],c=new_y.data.tolist(),cmap='jet')
xlim([-np.pi,np.pi])
ylim([-np.pi,np.pi])
cb = plt.colorbar()
xlabel(r'$\phi$')
ylabel(r'$\psi$')
cb.set_label("Neural Network Projection")

I got an error like


TypeError Traceback (most recent call last)
~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
131 try:
--> 132 rgba = _colors_full_map.cache[c, alpha]
133 except (KeyError, TypeError): # Not in cache, or unhashable.

TypeError: unhashable type: 'list'

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
3985 # must be acceptable as PathCollection facecolors
-> 3986 colors = mcolors.to_rgba_array(c)
3987 except ValueError:

~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/colors.py in to_rgba_array(c, alpha)
232 for i, cc in enumerate(c):
--> 233 result[i] = to_rgba(cc, alpha)
234 return result

~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
133 except (KeyError, TypeError): # Not in cache, or unhashable.
--> 134 rgba = _to_rgba_no_colorcycle(c, alpha)
135 try:

~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)
188 if len(c) not in [3, 4]:
--> 189 raise ValueError("RGBA sequence should have length 3 or 4")
190 if len(c) == 3 and alpha is None:

ValueError: RGBA sequence should have length 3 or 4

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
in ()
----> 1 scatter(plot_feat[:,0],plot_feat[:,1],c=new_y.data.tolist(),cmap='jet')
2 xlim([-np.pi,np.pi])
3 ylim([-np.pi,np.pi])
4 cb = plt.colorbar()
5 xlabel(r'$\phi$')

~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, hold, data, **kwargs)
3376 vmin=vmin, vmax=vmax, alpha=alpha,
3377 linewidths=linewidths, verts=verts,
-> 3378 edgecolors=edgecolors, data=data, **kwargs)
3379 finally:
3380 ax._hold = washold

~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/init.py in inner(ax, *args, **kwargs)
1715 warnings.warn(msg % (label_namer, func.name),
1716 RuntimeWarning, stacklevel=2)
-> 1717 return func(ax, *args, **kwargs)
1718 pre_doc = inner.doc
1719 if pre_doc is None:

~/miniconda2/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
3989 msg = ("c of shape {0} not acceptable as a color sequence "
3990 "for x with size {1}, y with size {2}")
-> 3991 raise ValueError(msg.format(c.shape, x.size, y.size))
3992 else:
3993 colors = None # use cmap, norm after collection is created

AttributeError: 'list' object has no attribute 'shape'

Any idea how to solve it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions