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 on Colab not displaying chart

    General Discussion
    6
    13
    2850
    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.
    • J
      Jafsa last edited by

      Hi,

      I searched the forums but couldn't find a solution.
      I'm using Google Colab. Build a strategy. Works.
      I now try to use cerebro.plot() but cannot see the chart, only get [[<Figure size 432x288 with 5 Axes>]]

      Any help would be appreciated.

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

        Try putting plt.show() after cerebro.plot()

        RunBacktest.com

        J 1 Reply Last reply Reply Quote 1
        • J
          jf last edited by

          I was struggling with the same problem, this is some kind of workaround...

          from google.colab import files
          cerebro.plot()[0][0].savefig('samplefigure.png', dpi=300)
          files.download('samplefigure.png')
          
          K 1 Reply Last reply Reply Quote 0
          • J
            Jafsa @run-out last edited by

            @run-out
            Didn't work

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

              OK, it was a shot in the dark.

              RunBacktest.com

              1 Reply Last reply Reply Quote 0
              • J
                Jafsa last edited by

                Does this means you can't plot with backtrader on colab? That is a pity.

                run-out A 3 Replies Last reply Reply Quote 0
                • run-out
                  run-out @Jafsa last edited by

                  @Jafsa said in cerebro.plot on Colab not displaying chart:

                  Does this means you can't plot with backtrader on colab? That is a pity.

                  No it means I haven't used Colab with backtrader. I've seen discussions online regarding this issue, it might have been solved somewhere.

                  RunBacktest.com

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

                    @Jafsa said in cerebro.plot on Colab not displaying chart:

                    Does this means you can't plot with backtrader on colab? That is a pity.

                    Also have a look at this plotting library. Might solve your problem.

                    RunBacktest.com

                    1 Reply Last reply Reply Quote 0
                    • A
                      ab_trader @Jafsa last edited by

                      @Jafsa said in cerebro.plot on Colab not displaying chart:

                      Does this means you can't plot with backtrader on colab? That is a pity.

                      Does this work?
                      https://community.backtrader.com/post/13058

                      • If my answer helped, hit reputation up arrow at lower right corner of the post.
                      • Python Debugging With Pdb
                      • New to python and bt - check this out
                      J 1 Reply Last reply Reply Quote 0
                      • J
                        Jafsa @ab_trader last edited by

                        @ab_trader Thank you for the link, but I'm not sure it is related to my issue.

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

                          Now I can see plot as image.

                          https://colab.research.google.com/drive/1VmCv3J6_nZRDFsQ_yoPTvGNCpaswvbN_?usp=sharing

                          1 Reply Last reply Reply Quote 2
                          • K
                            kenorb @jf last edited by

                            @jf Similar workaround to display in Colab:

                            from google.colab import files
                            from IPython.display import Image
                            chart_file = 'result.png'
                            cerebro.plot()[0][0].savefig(chart_file, dpi=300)
                            Image(open(chart_file, 'rb').read())
                            
                            1 Reply Last reply Reply Quote 1
                            • K
                              kenorb last edited by

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

                              1 Reply Last reply Reply Quote 0
                              • 1 / 1
                              • First post
                                Last post
                              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors