I want to tag every point that I drew in python, and I have not found a suitable way to do this.
Assuming that I have two lists of elements ncalled aand b, I print them as follows:
n
a
b
plt.figure() plt.grid() plt.plot(a , b , 'bo') plt.show()
I want each dot to indicate "Variable k" from kfrom 1to n. thank you for your time
k
1
Here is the best way to do this, I found:
plt.figure() plt.scatter(a,b) labels = ['Variable {0}'.format(i+1) for i in range(n)] for i in range (0,n): xy=(a[i],b[i]) plt.annotate(labels[i],xy) plt.plot()
Additional information: Matplotlib: how to place individual tags for a scatter plot
label
x = np.random.random(3) y = np.random.random(3) z = np.arange(3) colors = ["red", "yellow", "blue"] c = ["ro", "yo", "bo"] for i in z: plt.plot(x[i], y[i], c[i], label=colors[i] + ' ' + str(i)) plt.legend()
Source: https://habr.com/ru/post/1665028/More articles:Shapovy intersections against harmonious relations - inaccurate? - pythonShould I explicitly destroy objects in order - c ++NSOpenPanel / NSSavePanel crashes in Swift 3 - swift3Could be reasonably implemented within .net? - .netRules in Firebase database revert to original - firebasehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1665029/intellij-coding-style-quesiton&usg=ALkJrhgNvj_tWl_F7ZfO2sjbs_oFyVYSWgWhy does list classification slow down the lengths () function? - performanceAsp.net Core Get user by user id - asp.net-coreHow to remove observers created by angular directives after compilation - angularjsHow to encode theft of the sidebar in shiny to show only icons - htmlAll Articles