1

I'm trying to plot candlestick_ohlc with ticks of 1 minute and the graph looks like this:

plot result

I looked on the site and i tried to implement all the answers about questions like this, and yet, the result was the same grpah.

I think the the problem is in the tick rate of the x axis, but cant figure how to fix it.

Here is the part from the code that plotting the graph: (the prints are there so you will be able to understand which data is used (added pastebin link)

print(data_ohlc)
df_ohlc = pd.DataFrame(data_ohlc, columns=['Date', 'Open', 'High', 'Low', 'Close'])
print(df_ohlc)
df_ohlc['Date'] = df_ohlc['Date'].map(mdates.date2num)
print(df_ohlc['Date'])
fig, ax = plt.subplots()
fig.subplots_adjust(bottom=0.2)
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M'))
candlestick_ohlc(ax, df_ohlc.values, width=2, colorup='g')
plt.show()

the data i used can be found here:

https://pastebin.com/qm5KFyrx
Udi Vahaba
  • 13
  • 3

1 Answers1

0

You're trying to fit 3 days worth of 1 minute data (that's 24 * 60 * 3 = 4320 points) into a 300x400 pixel picture? No wonder it won't fit. Try to display the smaller sections of your data, take first 100 points for example, work with them -- I'm sure you'll get the reasonable picture from that.

lenik
  • 23,228
  • 4
  • 34
  • 43
  • @UdiVahaba this works for me: `candlestick_ohlc( ax, ohlc, width=0.6, colorup='#77d879', colordown='#db3f3f', alpha=0.3 )` (with my data) – lenik Jun 30 '18 at 17:08
  • @UdiVahaba on your `plot result` I can see 2018-06-28, 2018-06-29, 2018-06-30 along the X axis -- how did these values get there if you have only 100 points with 1 minute interval -- approx 1.5 hours worth of data? – lenik Jun 30 '18 at 17:12
  • the picture shows the problem, but as you can see on pastebin there are exacly 100 points – Udi Vahaba Jun 30 '18 at 17:13
  • 1
    @UdiVahaba I'd really appreciate if you reduce the opacity to 0.3, bar width to 0.6, as in my example, and make another picture with 100 points and attach that one to your question, if you need my help. thanks! – lenik Jun 30 '18 at 17:17
  • thanks, width was the problem. had to change it over to 0.0005 – Udi Vahaba Jun 30 '18 at 19:34