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/

    Plots overwriting each other in Jupyter Notebook

    General Code/Help
    2
    4
    351
    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.
    • F
      floomi last edited by

      Hi all,

      I'm using Backtrader in a Jupyter notebook. I'm generating a Cerebro instance, adding some indicators, and doing a plot in two separate cells. When I run the second cell, it overwrites the plot from the first cell:

      13551add-4109-4703-8f2e-7fdf79ddab7b-image.png

      I'd like the first graph under the first cell and the second graph under the second cell. I've put plt.figure in between the two and that hasn't worked. I'm using the %matplotlib notebook magic; I've also tried %matplotlib inline and iplot=False to no avail.

      Any help? Thanks!

      F 1 Reply Last reply Reply Quote 0
      • F
        floomi @floomi last edited by

        Sorry, I trimmed off the crucial bottom of the screenshot. Updated version:

        27983879-0afc-45e2-b465-abaa3b5aa495-image.png

        1 Reply Last reply Reply Quote 0
        • run-out
          run-out last edited by

          This is a shot in the dark, I haven't tried to reproduce. But maybe try in the first cell:

          fig1 = cerebro.plot()
          fig1.show()
          

          and in the second cell:

          fig2 = cerebro.plot()
          fig2.show()
          

          RunBacktest.com

          1 Reply Last reply Reply Quote 0
          • F
            floomi last edited by

            I see what you're going for, yeah. Alas:

            ---------------------------------------------------------------------------
            AttributeError                            Traceback (most recent call last)
            <ipython-input-5-b8fba0c10c1f> in <module>
                  6 cerebro.run()
                  7 fig = cerebro.plot()
            ----> 8 fig.show()
            
            AttributeError: 'list' object has no attribute 'show'
            
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors