i am developing a financial graph using candlesticks. i face two different problems with the candels width: — they are too large — they are too small
depending on the amount of data in the interval i have.
i know i can control it with width
param:
candlestick_ohlc(ax1, data, width=candel_width, colorup='g', colordown='r')
but i am looking for if there is a parameter that automatically handle the cases.
my code is: fig, ax1 = pyplot.subplots(figsize=(10, 5))
for i in ohlc:
i['time'] = date2num(datetime.datetime.fromtimestamp(i['time']))
data = []
for i in ohlc:
sub_lst = i['time'], i['open'], i['high'], i['low'], i['close']
data.append(sub_lst)
candlestick_ohlc(ax1, data, width=candel_width, colorup='g', colordown='r')
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%d-%m %H:%M'))
ax1.xaxis.set_major_locator(ticker.MaxNLocator(10))
ax1.grid(True)
pyplot.xlabel('Date')
pyplot.ylabel('Price')
pyplot.title(title)
pyplot.tight_layout()
fig.autofmt_xdate()
ax1.autoscale_view()
pyplot.show()