我15/10/2017
matplotlib 3D散點圖日期
我試圖日期的格式列表如下
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'對象的散佈方法。嘗試用'ax = fig.add_subplot(111,projection ='3d')'創建一個'Axes3d'對象,然後完成你所做的事情。 –
已經嘗試過並更新了問題 –