2
我想在圖例中顯示顏色和標記。顏色意味着一件事,標記意味着另一件事它應該看起來像附加的圖像。這是當前的代碼,我有:如何創建顏色和標記的圖例?
x = np.arange(20)
y = np.sin(x)
fig, ax = plt.subplots()
line1 = ax.scatter(x[:10],y[:10],20, c="red", picker=True, marker='*')
line2 = ax.scatter(x[10:20],y[10:20],20, c="red", picker=True, marker='^')
ia = lambda i: plt.annotate("Annotate {}".format(i), (x[i],y[i]), visible=False)
img_annotations = [ia(i) for i in range(len(x))]
def show_ROI(event):
for annot, line in zip([img_annotations[:10],img_annotations[10:20]], [line1, line2]):
if line.contains(event)[0]:
...
fig.canvas.draw_idle()
fig.canvas.mpl_connect('button_press_event', show_ROI)
plt.show()
你的意思是兩個獨立的傳說? – DavidG
@DavidG,它可以是一個圖例或兩個單獨的圖例,但標記不是顏色特定的。標記可以有不同的顏色。一種顏色可以有不同的標記。 – matchifang
你能否提供一個預期/期望結果的例子(最好是圖片)? – DavidG