1
plt.figure()
#new point 1
x_features_new1 = np.array([[0,-1]])
plt.scatter(x_features_new1[:,0],x_features_new1[:,1],s=50,cmap='viridis')
plt.annotate(s='New point 1',xy=(0,-1),xytext=(-2,0),color='blue',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red'))

When I run above codes in Jupyter Lab,the problem notes as follows:

TypeError                                 Traceback (most recent call last)
C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_13960/202384759.py in <module>
      4 x_features_new1 = np.array([[0,-1]])
      5 plt.scatter(x_features_new1[:,0],x_features_new1[:,1],s=50,cmap='viridis')
----> 6 plt.annotate(s='New point 1',xy=(0,-1),xytext=(-2,0),color='blue',arrowprops=dict(arrowstyle='-|>',connectionstyle='arc3',color='red'))
      7 
      8 #new point2

TypeError: annotate() missing 1 required positional argument: 'text'

How to solve this problem?

gongwanyi
  • 35
  • 2
  • 4
  • 2
    insted of `s= New point 1` use `text=New Point 1` – Bhavya Parikh Dec 17 '21 at 06:26
  • See [Positional argument v.s. keyword argument](https://stackoverflow.com/questions/9450656/positional-argument-v-s-keyword-argument) and [`annotate` documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.annotate.html) – AJ Biffl Dec 17 '21 at 06:27

0 Answers0