For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Plot doesn't show up when running the code



  • Hi all, I'm relatively new to Python. I'm doing my first steps with Backtrader and tried to run the sample code. I got a problem concerning the plot. The code runs fine but when it comes to the plot I only get the following output but not plot:

    [[<Figure size 640x480 with 5 Axes>]]

    I'm using the Anaconda-Distribution with Python 3.7 and Spyder on Win 10.
    Probably it's a noob question but I don't know how to solve this 'problem'.

    Thanks in advance


  • administrators

    @knolch said in Plot doesn't show up when running the code:

    [[<Figure size 640x480 with 5 Axes>]]

    That's the result of this in the code

    cerebro.plot()
    

    Because plot does actually return the created matplotlib figure, should the user desire to do something with it. If you were assigning the return value to a variable, you wouldn't see that.

    The problem is Spyder. The configuration you have is preventing the chart from being displayed. Your options:

    • Try

      cerebro.plot(iplot=False)
      

      This disables automatic inline plotting detection in backtrader, but this is probably not going to help.

    • Have a look at the charting options in Spyder for plotting. If set to automatic, change it to inline and viceversa.

    It's the problem with this Python kernel hijacking shells: they think they know better.



  • @backtrader
    Thanks for your reply.
    I followed your steps but unfortunately it didn't work.
    I then switched to the standard Python IDLE as you mentioned it's a problem with Spyder and it worked out.

    I will not use Spyder now for developing and testing my trading strategies but do you have any recommendations what I could use instead?
    I mean IDLE works but it's very uncomfortable. Which Editor are you using for backtesting?

    Thanks for your help!


  • administrators

    @knolch said in Plot doesn't show up when running the code:

    I will not use Spyder now for developing and testing my trading strategies but do you have any recommendations what I could use instead?
    I mean IDLE works but it's very uncomfortable. Which Editor are you using for backtesting?

    Apparently people like PyCharm for which a Free Community edition is available.

    Unless you are comfortable with vim or emacs and don't mind using a standard shell (which for all intent and purposes happens to be bash these days)