plt.plot散点图输出问题



运行此代码块后,我收到"转换错误"消息:

import matplotlib.pyplot as plt
plt.figure(figsize=(12.2, 4.5))
plt.title('Buy and Sell Plot', fontsize = 18)
plt.plot(df['Close'], label = 'Close Price', color = 'blue', 
alpha = 0.35)
plt.plot(ShortEMA, label = 'Short/Fast EMA', color = 'red', 
alpha = 0.35)
plt.plot(MiddleEMA, label = 'Middle/Medium EMA', color = 
'orange', alpha = 0.35)
plt.plot(LongEMA, label = 'Long/Slow EMA', color = 'green', 
alpha = 0.35)
plt.scatter(df.index, df['Buy'], color = 'green', 
marker='^', alpha = 1)
plt.scatter(df.index, df['Sell'], color = 'red', marker='v', 
alpha = 1)
plt.xlabel('Date', fontsize = 18)
plt.ylabel('Close Price', fontsize = 18)
plt.show()

任何见解都将不胜感激

这可能是由于;CCD_ 1(…(";部分如果运行type(df.index),您会看到它是一个pandas.core.indexes.range.RangeIndex,而不是一个数组。试着用np.asarray(auc_df.index)运行它,希望它能解决这个问题!

最新更新