x_G = np.array([12, 210, 80, 165, 150, 272, 10, 7.5])
y_G = np.array([20.0, 40.0, 60.0, 60.0, 60, 80, 8, 20])
names_G = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
for x, y in zip (x_G, y_G):
plt.annotate(names_G, (x, y), textcoords='offset points', xytext=(0, 10), ha='center')
So I know the first argument, names_G
is wrong, and makes no sense but I'm unsure how to get the first label 'A'
, to correspond to the (12,20.0) point and so on.
If anyone could point me in the right direction, that would be great thanks.
CodePudding user response:
There isn't any problem in including the text in the zip:
for x, y, t in zip (x_G, y_G, names_G):
plt.annotate(t, (x, y), textcoords = 'offset points', xytext=(0,10), ha='center')
As an alternative to defining your list of names manually, you may want to get a list of characters:
import string
names = string.ascii_uppercase