import matplotlib.pyplot as plt
import numpy as np
x = np.array([0,0,0,0,1]) # x = data_graph.x.values
y = np.array([1,2,3,4,1]) # y = data_graph.y.values
color = np.array(['black', 'black', 'red', 'yellow', 'green']) # color = data_graph.color.values
types = np.array(['type1','type2','type3','type4','type5']) # types = data_graph.type.values
for i in range(np.unique(color).shape[0]):
x_plot = x[color== np.unique(color)[i]]
y_plot = y[color== np.unique(color)[i]]
c = np.unique(color)[i]
label = np.unique(color)[i] +'_' + types[i]
plt.scatter(x_plot,y_plot, c = c, label=label)
plt.legend()
plt.show()
Или в зависимости от того, что вам нужно:
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0,0,0,0,1]) # x = data_graph.x.values
y = np.array([1,2,3,4,1]) # y = data_graph.y.values
color = np.array(['black', 'black', 'red', 'yellow', 'green']) # color = data_graph.color.values
types = np.array(['type1','type2','type3','type4','type5'])
for i in range(np.unique(types).shape[0]):
x_plot = x[types== np.unique(types)[i]]
y_plot = y[types== np.unique(types)[i]]
c = color[types==types[i]][0]
label = c +'_' + types[i]
plt.scatter(x_plot,y_plot, c = c, label=label)
plt.legend()
plt.show()
Или в зависимости от того, что вам нужно:
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0,0,0,0,1]) # x = data_graph.x.values
y = np.array([1,2,3,4,1]) # y = data_graph.y.values
color = np.array(['black', 'black', 'red', 'yellow', 'green']) # color = data_graph.color.values
types = np.array(['type1','type2','type3','type4','type5'])
texts = np.array([20,30,40,50,60])
for i in range(np.unique(types).shape[0]):
x_plot = x[types== np.unique(types)[i]]
y_plot = y[types== np.unique(types)[i]]
c = color[types==types[i]][0]
label = c +'_' + types[i]
plt.scatter(x_plot,y_plot, c = c, label=label)
for i, txt in enumerate(texts):
plt.annotate(txt, (x[i], y[i]))
plt.legend()
plt.show()