show() appends instead of overwriting

I’ve noticed that if I execute a Bokeh script multiple times inside a Jupyter session or even in a plain Python interactive session, the output HTML file size increases in each execution.

For example:

from bokeh.plotting import figure
from bokeh.io import output_file, show, save
x=[1,2,3]
y=[6,7,8]
output_file(“Line.html”)

p=figure()

p.line(x,y)

show(p)

``

That will create a 7 KB file first, and then every time I execute the cell, it adds 6 more KB to the file. I looked at the HTML file source code and it seems the input data are being appended to the JSON string multiple times. Same behavior if I execute those lines one by one in a simple Python shell more than once.

I also noticed that using save() instead of show() doesn’t increase the size of the produced file. So, the key seems to be the show() method.

Is this expected behavior? Anyone could explain the rationale behind this?

Hi Adi,

      I believe there's an

open issue about this. It’s a non trivial problem.

          This doesn't happen

outside an interactive session.

There are workarounds.

Sincerely,

Sarah Bird

···

On 8/23/16 1:58 AM, Adi wrote:

    I've noticed that if I execute a Bokeh script

multiple times inside a Jupyter session or even in a plain
Python interactive session, the output HTML file size increases
in each execution.

For example:

from bokeh. plotting
import
figure

            from bokeh.io import
              output_file, show, save

              x=[1,2,3]

              y=[6,7,8]

              output_file("Line.html")



              p=figure()



              p.line(x,y)



              show(p)

``

      That will create a 7 KB file first, and then every time I

execute the cell, it adds 6 more KB to the file. I looked at
the HTML file source code and it seems the input data are
being appended to the JSON string multiple times. Same
behavior if I execute those lines one by one in a simple
Python shell more than once.

      I also noticed that using save() instead of show() doesn't

increase the size of the produced file. So, the key seems to
be the show() method.

      Is this expected behavior? Anyone could explain the

rationale behind this?

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected].

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/bae71a6f-d095-45aa-9576-7897a59eb110%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/bae71a6f-d095-45aa-9576-7897a59eb110%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

As Sarah said, known issue. Current workaround

Try adding

from bokeh.io import reset_output()

``

and then this where you want to reset, maybe at the top of your script or plotting function

reset_output()

``

···

On Tuesday, 23 August 2016 10:08:12 UTC+1, Sarah Bird wrote:

Hi Adi,

      I believe there's an

open issue about this. It’s a non trivial problem.

          This doesn't happen

outside an interactive session.

There are workarounds.

Sincerely,

Sarah Bird

On 8/23/16 1:58 AM, Adi wrote:

    I've noticed that if I execute a Bokeh script

multiple times inside a Jupyter session or even in a plain
Python interactive session, the output HTML file size increases
in each execution.

For example:

from bokeh. plotting
import
figure

            from bokeh.io import
              output_file, show, save

              x=[1,2,3]

              y=[6,7,8]

              output_file("Line.html")



              p=figure()



              p.line(x,y)



              show(p)

``

      That will create a 7 KB file first, and then every time I

execute the cell, it adds 6 more KB to the file. I looked at
the HTML file source code and it seems the input data are
being appended to the JSON string multiple times. Same
behavior if I execute those lines one by one in a simple
Python shell more than once.

      I also noticed that using save() instead of show() doesn't

increase the size of the produced file. So, the key seems to
be the show() method.

      Is this expected behavior? Anyone could explain the

rationale behind this?

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected].

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/bae71a6f-d095-45aa-9576-7897a59eb110%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/bae71a6f-d095-45aa-9576-7897a59eb110%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" style="width:150px;min-height:30px" height="30px" width="150px">
    ](http://continuum.io)

Hello,

I am trying to use the WMTS tile source to load tiles on behind my data (lat/lon points & lines). I need to use my company’s provided WMTS server, but have a problem where the western hemisphere is simply tiled over and over and over again, zooming in and out works find for this hemisphere, but I never get the eastern hemisphere loaded.

I’m using the tutorial provided here (https://www.youtube.com/watch?v=YAls_da1cF4) to add the tiles.

An important note is that the company WMTS server’s tile url flops the X & Y so that a url which would be “…/MapServer/tile/{Z}/{X}/{Y}” is “{Z}/{Y}/{X}” on our server but I’ve been digging through bokeh’s code and cannot find a specific place where this flop would be material (since you’re mostly using replace statements etc).

Has anybody seen this issue before? Do you have any suggestions?

···

Sophie Wagner
[email protected]