【发布时间】:2016-06-14 11:30:45
【问题描述】:
我正在尝试创建散点图。我有一个从 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''
此错误消息是什么意思?如何将数据绘制为散点图?
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()
【问题讨论】:
标签: python numpy matplotlib