I'm using the scatter function from the matplotlib.pyplot library to visualize certain data in a 3D scatter plot. This function, Link to documentation , has an argument called 'c' which can be used to give the marker a particular color.
They note that the argument given for 'c' can be a RGB code stored in a 2D array. However when i try the code below it gives an error: "AttributeError: 'list' object has no attribute 'shape'".
My Question: Is it possible to give the markers in the scatter plot a custom color from the RGB format? And if it is, how can i achieve this?
Any help would be greatly appreciated.
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import csv
RGB = [[255,255,255], [127,127,127], [10,10,10]]
r = []
g = []
b = []
a = 0
i = 0
j = 0
k = 0
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
mark = (".",",","o","v","^","<",">","1","2","3","4","8","s","p","P","*","h","H","+","x","X" ) # tuple for available markers from the matplotlib library
with open ('Color_Measurement_POCNR1_wolkjes.csv', 'r') as csvfile:
plots = csv.reader(csvfile, delimiter = ';')
for row in plots:
if a == 1:
r.append(float(row[6]))
g.append(float(row[7]))
b.append(float(row[8]))
print("j = ", j, "r = ", r[j]," g = ", g[j], " b = ", b[j])
ax.scatter(r[j], g[j], b[j], c= RGB[0], marker = mark[k] , s = 50)
a = 0
j += 1
k += 1
if row[0] == "Mean values":
a += 1
ax.set_xlabel('R Label')
ax.set_ylabel('G Label')
ax.set_zlabel('B Label')
plt.show()