14
我正在尝试创建一个散点图。我有一个从0到17的数字列表以及一个有18个值的数组。我可以将数据绘制为线图,但是当我尝试绘制散点图时,我收到一条错误消息,我不明白:TypeError: ufunc 'sqrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Matplotlib散布图与未知错误
这条错误消息的含义是什么,如何获取要绘制的数据作为分散?
import numpy as np
import matplotlib.pyplot as plt
y = [7316.0, 7453.25, 7518.25, 7711.5, 7448.0, 7210.25, 7416.75, 6960.75,
7397.75, 6397.5, 5522.75, 5139.0, 5034.75, 4264.75, 5106.0, 3489.5,
4712.0, 4770.0]
x = np.arange(0,18,1)
plt.rcParams['legend.loc'] = 'best'
plt.figure(1)
plt.xlim(0, 20)
plt.ylim(0, 10000)
plt.scatter(x, y, 'r')
plt.show()
谢谢你现在有道理。我正在阅读它,但省略了c =部分,因为它在正常情节中是不必要的。在两种风格之间有不同的语法似乎很愚蠢。 –