I'm struggling with plot of time from dataframe. After many tries and almost every error, I just ploted ticks with set_xtickslabels
, but date didn't match to chart...showed next items from the list on every printed tick. And also when pointed on chart date was not in correct format. This wasn't supprise, because ploted this with float. Through all those readings on stack forum I get to that date is an object, and tried to format it in many ways, but still didn't get to correct solution. So how to do it correctly or where to look for solution?
This is history(for sure not all of them) of my strugglings and errors that I got:
def getCandles(df, ax):
ohlc = df[['open_time','o', 'h', 'l', 'c', 'v']].copy()
ohlc['open_time'] = ohlc['open_time'].values.astype(float)
ohlc['o'] = ohlc['o'].astype(float)
ohlc['h'] = ohlc['h'].astype(float)
ohlc['l'] = ohlc['l'].astype(float)
ohlc['c'] = ohlc['c'].astype(float)
ohlc['v'] = ohlc['v'].astype(float)
candlestick_ohlc(ax, ohlc.values, width = 0.8, colorup="#77d879", colordown="#db3f3f")
plt.xlabel('TIME')
plt.ylabel('PRICE')
plt.tight_layout()
plt.show()
EDIT: I found a solution here: https://stackoverflow.com/a/41822115/6635518
Thanks All for help.