0
for symbol in symbols:
    data = con.get_candles(symbol, period='D1', start = start, end = end)
    data1 = con.get_candles('USOil', period='D1', start = start1, end = end)
    ax = data['bidclose'].plot()
    data1['bidclose'].plot(ax=ax)

I have used the code above in the hope that it will plot symbol and usoil in 1 chart and then produce another chart with the next in line symbol and usoil until all the symbol list has been exhaused. However evertything is getting plotted in the same chart.

enter image description here

How can i use the for-loop where 1 symbol in the list of symbols and usoil get plotted? Thus there will be n numbers of plots where n is the number of symbol in symbols.

3
  • I think you could create a new figure everytime through the loop. Commented Dec 2, 2019 at 13:12
  • @user1558604 I thought so too but everything is getting plotted in the same chart! I am actually trying to recreate an errorValueError: cannot reindex from a duplicate axis I hoped it would show up but for some reason it did not! Commented Dec 2, 2019 at 13:14
  • This is why I like the object-oriented way, it takes a bit longer to write but you have better control (/ comprehension) over what ax and figure are shown. It allows to manually open/save/close figures. Commented Dec 2, 2019 at 13:26

1 Answer 1

1

Just put plt.show() in your routine:

for symbol in symbols:
    data = con.get_candles(symbol, period='D1', start = start, end = end)
    data1 = con.get_candles('USOil', period='D1', start = start1, end = end)
    ax = data['bidclose'].plot()
    data1['bidclose'].plot(ax=ax)
    plt.show()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.