In case someone tries to apply the above solutions to .scatter () instead of .subplot (),
I tried to run the following code
y = [2.56422, 3.77284, 3.52623, 3.51468, 3.02199] z = [0.15, 0.3, 0.45, 0.6, 0.75] n = [58, 651, 393, 203, 123] fig, ax = plt.scatter(z, y) for i, txt in enumerate(n): ax.annotate(txt, (z[i], y[i]))
But I came across errors that said that "it is impossible to unpack a non-repeatable PathCollection object", and the error points to the code line fig, ax = plt.scatter (z, y)
I eventually resolved the error using the following code
plt.scatter(z, y) for i, txt in enumerate(n): plt.annotate(txt, (z[i], y[i]))
I did not expect that there would be a difference between .scatter () and .subplot (), I should have known better.
Heather Claxton Mar 28 '19 at 2:11 2019-03-28 02:11
source share