Stone-Soup icon indicating copy to clipboard operation
Stone-Soup copied to clipboard

Plotter & Plotterly figures do not display automatically when scripts/functions are ran from the command line/IDE

Open gawebb-dstl opened this issue 2 years ago • 2 comments

Figures from the Plotter and Plotterly class don't automatically appear when the scripts are ran in Pycharm or the command line. I expect they won't display when ran from other IDEs.

For each the figures can made to display: For the Plotterly class using: plotter.fig.show() instead of plotter.fig makes the figures appear. However using plotter.fig.show() in the tutorials breaks the Sphinx docs. For the Plotter class, plt.show() is needed at the end of the script to force the figures to appear.

I feel this behaviour could trip up people who are new to Stone-Soup when they try to run the tutorials or examples

gawebb-dstl avatar Oct 12 '22 20:10 gawebb-dstl

Not exactly similar but if someone is using Spyder (IDE bundled with Anaconda), even adding plt.show() doesn't render figures. You need to manually change the default spyder renderer to browser by first importing import plotly.io as pio and then setting renderer to the browser by pio.renderers.default ='browser'.

khurramkhalil avatar Oct 18 '22 05:10 khurramkhalil

I believe this is a (somewhat) known problem with plot.ly (which Plotterly is using internally). For example, see these links (generally in decreasing order of usefulness)

Basically, it sounds like plotly opens up a web server but for some reason that web server sometimes gets shut down before the web browser accesses it. Solutions are to either (a) run things in a Jupyter notebook or (2) use plotter.fig.write_html('desired_filename.html') and then click on the .html file.

What we have started doing is calling write_html followed by show(). About 50% of the time, show works, so no problem. When it doesn't work, we double-click on the generated html file and it opens up in the browser without a problem.

cntaylor avatar Nov 30 '22 22:11 cntaylor