Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    cerebro.plot() does not work with Anaconda / IPython

    General Code/Help
    5
    6
    2440
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      itsmi last edited by

      It appears that the cerebro.plot() command only works in Jupyter, but not in IPython (similarly here). I get the following error:
      <IPython.core.display.Javascript object>
      <IPython.core.display.HTML object>

      Any suggestions on how to overcome the issue? Thanks!

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        Not being even a beginner in the usage of IPython

        1. Anaconda has nothing to do with this. It's a distribution.

        2. Jupyter is the graphical frontend and as such meant for plotting

        3. IPython is focused on interactive Python, i.e.: it is a console.

        Try plotting disabling the ipython automatic detection when calling plot

        • Docs - Cerebro
        1 Reply Last reply Reply Quote 0
        • I
          itsmi last edited by itsmi

          Thanks for the explanation. cerebro.plot(iplot=False) alongside changing the graphics backend in Spyder (Tools/Preferences/IPython Console/Graphics) now allows me to plot it via the IPython console.

          //edit: When I select "inline", it seems like it worked once, but now the figure window freezes. When I select "Automatic" or anything else, I get the error message "ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running". Any solution to this?

          //edit2: The freeze can be delayed by adding plt.pause(10) after cerebro.plot(iplot=False). In that case, i can at least see and 'use' the figure. I would still be happy about comments on it. Thanks!

          1 Reply Last reply Reply Quote 0
          • sobeasy
            sobeasy last edited by

            having the same problems here, and no kidding, it was killing me.
            I spent hours and hours to figure the solution and even pycharm can't help. ( Don't know why )
            I tried subclass the "backtrader.plot.Plot" but still not working.

            If you really want to use spyder, here is the trick :

            import backtrader.plot
            import matplotlib
            matplotlib.use('QT5Agg')
            
            # Your running code
            
            cerebro.plot(iplot= False)
            

            Remember to select your Graphic backend to "Qt5" in spyder.
            You should see the windows pop out (It can even be maximizing ! how great...)

            I am using win10 , Anaconda , Spyder 3.3.2 , Py 3.7.1, Ipyhon 7.2.0

            (User from Hong Kong. Thanks for the platform, it's really great.)

            B 1 Reply Last reply Reply Quote 3
            • K
              kenorb last edited by

              Possible fix: https://github.com/mementum/backtrader/pull/423

              1 Reply Last reply Reply Quote 0
              • B
                BTUSER21 @sobeasy last edited by

                Thank you - this was very annoying, but your solution worked! :)

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
                $(document).ready(function () { app.coldLoad(); }); }