I am plotting a scatter plot in python and I want to track my plots based on the IDs and I get these ids from t.id in for loop. At the moment I am doing hard coding. Considering given ids are more than 10 or more and following code
ax.scatter(t.v, t.r)
if t.id == 0:
x_t1.append(t.v)
y_t1.append(t.r)
elif t.id == 1:
x_t2.append(t.v)
y_t2.append(t.r)
elif t.id == 2:
x_t3.append(t.v)
y_t3.append(t.r)
else:
x_t4.append(t.v)
y_t4.append(t.r)
ax.plot(x_t1, y_t1, marker = 'o', color = 'blue')
ax.plot(x_t2, y_t2, marker = 'o', color = 'green')
ax.plot(x_t3, y_t3, marker = 'o', color = 'yellow')
ax.plot(x_t4, y_t4, marker = 'o', color = 'red')
How can I plot without writing so many if lines? The plots should look different (Doesn't matter if colour is different or marker is different)
Aucun commentaire:
Enregistrer un commentaire