i am trying to generate a plot with annotations, the issue is that i have for each x value multiple y values correspond to it, so in order to keep x and y similar in size, i wrote the following:
x = [-2,-1,0,1,2]
y = [(22.8,19.6),(8.9,13.7,14.7),(1.9,-1.8),(-3,-5.9,-13.4),(-5.7,-6.8)]
however, i am constantly getting the follwoing warning:
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. _data = np.array(data, dtype=dtype, copy=copy,
my full code:
import matplotlib.pyplot as plt
import numpy as np
x = [-2,-1,0,1,2]
y = [(22.8,19.6),(8.9,13.7,14.7),(1.9,-1.8),(-3,-5.9,-13.4),(-5.7,-6.8)]
custom_annotations = ["K464E", "K472E", "K464", "M155E", "K472", "M155A", "Q539A", "M155R", "D244A", "E247A", "E247R", "D244K"]
plt.scatter(x, y, marker="o")
for i, txt in enumerate(custom_annotations):
plt.annotate(txt, (x[i], y[i]))
plt.savefig("1.png")
source https://stackoverflow.com/questions/71953835/how-to-tackle-numpy-warnings
Comments
Post a Comment