I have upgraded to matplotlib 3.0.2 and the script below I used to use for my 3d plots throws this error now: ValueError: RGBA values should be within 0-1 range
. Tested with the 2.0.2 version and it works there... Tried to google for similar issues but couldn't find a workaround so asking this smart community for help...
test = pd.DataFrame({'cluster': ["0", "1", "2"],
'x': [2, 3, 1],
'y': [10, 5, -2],
'z': [-10, -5, 2]})
fig = plt.figure(figsize=(7,7))
ax = Axes3D(fig)
x=test['x']
y=test['y']
z=test['z']
clusters = test['cluster']
ax.scatter(x, y, z, c=clusters, marker='x', cmap='tab20b', depthshade=False)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
Your clusters are strings. Prior to matplotlib 2.1 arrays were converted to numbers coincidentally such that the code would run. From matplotlib 2.1 you need to supply numbers in order to have them interpreted as such. E.g.
clusters = test['cluster'].astype(int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With