import matplotlib.pyplot as plt
def plot_strategy_results(self, strategy): """ Plots the strategy results in a chart. :param strategy: a strategy object that includes performance, portfolio value and other metrics. """ fig = plt.figure(figsize=(12, 6)) ax = fig.add_subplot(1, 1, 1)
ax.plot(strategy.performance.index, strategy.performance['Net P&L'])
ax.set_title('Strategy Results')
ax.set_ylabel('Net P&L')
ax.set_xlabel('Date')
plt.xticks(rotation=30)
plt.show()
如果使用上述代码仍然无法绘图,则可能是matplotlib版本问题。请更新matplotlib至最新版本并重试绘图。