9

Before I updated, I would run my script and output the html file. There would be my one plot in the window. I would make changes to my script, run it, output the html file, look at the new plot. Then I installed the library again to update it using conda. I made some changes to my script, ran it again, and the output file included both the plot before I made some changes AND a plot including the changes. I ran the script again out of curiosity. Three plots in the one file! Ran it again. Four! Deleted the html file (instead of overwriting). Five! Changed the name of the output html file. Six! I even tried changing the name of the script. The plots just keep piling up.

What's going on? Why is it plotting every version of the graph I've ever made?

oregano
  • 816
  • 9
  • 25

2 Answers2

10

as of 0.5.1 there is now bokeh.plotting.reset_output that will clear all output_modes and state. This is especially useful in situations where a new interpreter is not started in between executions (e.g., Spyder and the notebook)

bigreddot
  • 33,642
  • 5
  • 69
  • 122
1

are you running in a notebook? Or are you running "python myscript.py" several times? If the latter, I don't see how that's possible, but it would definitely be a bug. Can you post your script or a minimal example? If you make an issue on the Bokeh GH issue tracker we can take a look as well. https://github.com/ContinuumIO/bokeh/issues?labels=&page=1&state=open

bigreddot
  • 33,642
  • 5
  • 69
  • 122
  • I'm working in Spyder using the Anaconda interpreter. I tried running an example script from the bokeh website and had the same problem. However, I just installed PyCharm and tried it (still with the Anaconda interpreter) and everything works properly. This is obviously a workaround but I don't know why it wouldn't be working from Spyder. – oregano Jul 15 '14 at 22:38
  • OK so spyder has the option of starting a new interpreter every time you run a script, or using an existing interpreter. I believe the default behavior is now the latter. This is important because the plotting.py interface is a stateful, "session" interface akin to matlab. So if it is not starting a new interpreter when you run the script, it will still have your old plots laying around. You can check this option in "Run->Configure" You want the option "Execute in a new dedicated Python interpreter" – bigreddot Jul 17 '14 at 12:23
  • We are adding a `reset_output` function in an upcoming dev release that you could use to clear things if you really need to use the default mode in Spyder (I don't like the default mode personally, I always want a new interpreter) – bigreddot Jul 17 '14 at 12:24