0

I am trying to plot a 3D scatter plot in matplotlib and for some reason I keep getting this unrecognized marker error. I am not sure how to fix this error. This is my code so far:

def display_3d_data(lp) :   

fig = plt.figure(figsize = (8, 8))
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = lp["X"][:,0]
y = lp["X"][:,1]
z = lp["X"][:,2]
labels = lp["y"]
color = np.array(["red", "green"])
marker = np.array([".", "^"])

for i in range(len(x)) :
  ax.scatter(x[i], y[i], z[i],cmap=color,marker=marker)
ax.set_xlabel('Feature 1')
ax.set_ylabel('Feature 2')
ax.set_zlabel('Feature 3')
plt.show()   

%matplotlib notebook
display_3d_data(lp1)

This is the error I keep getting:

ValueError: Unrecognized marker style array(['.', '^'], dtype='<U1')

and for this I need a triangle and dot style marker.

Expected Output: output

  • [This](https://matplotlib.org/stable/api/markers_api.html) is the list of possible markers. Which marker style are you trying to use? – BigBen Feb 23 '22 at 18:42
  • Are you trying to cycle markers inside each scatter? I do not know if that is possible – azelcer Feb 23 '22 at 22:34
  • I am trying to use triangle and dot markers. I updated the question with what my output is supposed to be. – Rema Thomas Feb 24 '22 at 00:48
  • Well... without knowing what `lp` is it is really difficult to understand. I imagine that `len(x)`is 2 and you want to use one marker for the first set and another one for the second. I am right? Do you always have only two datasets? – azelcer Feb 24 '22 at 01:02
  • I'm supposed to be using the sklearn.dataset make_blobs and here is what my code for lp1 is: lp1 = make_3d_Gaussian_Clusters(200, np.array([[-2,2,2],[2,2,2]]), 7) – Rema Thomas Feb 24 '22 at 01:15

0 Answers0