Overlapping Dates in Candlestick Plot from a Pandas DataFrame

ぃ、小莉子 提交于 2019-11-30 05:09:26

You can rotate the dates by adding:

for label in ax1.xaxis.get_ticklabels():
    label.set_rotation(45)

above your plt.show()

Pandas will also do this for you if you were to add a moving average with something like:

df_ohlc['10MA'] = pd.rolling_mean(ohlc['close'], 10)
df_ohlc['10MA'].plot(ax=ax1, label = '10MA')

As I understand, you're not seeing the legend because the candlestick chart is understood and needs no labeling. However, if you were to add the moving average, it's 'label = 10MA' would show up in a legend.

I hope this is as helpful as it is late. I came across this post while searching for other help.

The following code resolves data overlapping issue

fig.autofmt_xdate()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!