cerebro.plot on Colab not displaying chart
-
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.
-
Try putting plt.show() after cerebro.plot()
-
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')
-
@run-out
Didn't work -
OK, it was a shot in the dark.
-
Does this means you can't plot with backtrader on colab? That is a pity.
-
@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.
-
@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.
-
@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 -
@ab_trader Thank you for the link, but I'm not sure it is related to my issue.
-
Now I can see plot as image.
https://colab.research.google.com/drive/1VmCv3J6_nZRDFsQ_yoPTvGNCpaswvbN_?usp=sharing
-
@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())
-
Possible fix: https://github.com/mementum/backtrader/pull/423