【发布时间】:2017-03-08 16:49:25
【问题描述】:
我有一个格式为15/10/2017的日期列表
我已经尝试了以下
from matplotlib import pyplot
import pandas as pd
dates = ['15/10/2016', '16/10/2016', "17/10/2015", "15/10/2014"]
dates_formatted = [pd.to_datetime(d) for d in dates ]
x = [1,2,3,4]
z = [5,6,7,8]
pyplot.scatter(x, dates_formatted, z)
pyplot.show()
它会抛出一个错误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''
它显示它是否是 2D。例如pyplot.scatter(x, dates_formatted)
我也尝试了以下
ax = Axes3D(fig)
ax = fig.add_subplot(111,projection='3d')
ax.scatter(x, dates_formatted, y)
pyplot.show()
它会抛出一个错误Float() argument must be a string or number
【问题讨论】:
-
我怀疑您实际上是在调用常规
Axes对象的 scatter 方法。尝试使用ax = fig.add_subplot(111,projection='3d')创建一个Axes3d对象,然后执行您已完成的操作。 -
试过了,更新了问题
标签: python matplotlib plot