figures accumulated into output file

Hello,

The way figures get accumulated into html output files seems like a bug, unless I’m missing something.

In the example below, out1.html contains the first figure (the sine wave), but out2.html contains both figures.

I’d expect and I want out2.html to only contain the second figure.

What’s going on here? thanks.

···

#################

import numpy as np

from bokeh.plotting import *

N = 100

x1 = np.linspace(0, 4*np.pi, N)

y1 = np.sin(x1)

x2 = np.linspace(0, 10, N)

y2 = np.exp(x2)

output_file(‘out1.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x1, y1, legend=“sin(x)”)

save()

output_file(‘out2.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x2, y2, legend=“exp(x)”)

save()

Hi,

···

On Fri, Nov 7, 2014 at 6:38 PM, Kamel [email protected] wrote:

Hello,

The way figures get accumulated into html output files seems like a bug, unless I’m missing something.

In the example below, out1.html contains the first figure (the sine wave), but out2.html contains both figures.

I’d expect and I want out2.html to only contain the second figure.

What’s going on here? thanks.

This is because output_* (file, server, notebook) don’t reset the global state. They used to do this but this was changed at some point. As a workaround you should use reset_output() before second invocation of output_file(). I’m pretty sure the original behaviour will be restored in the upcoming version of bokeh (Bryan, please correct me if I’m wrong).

Mateusz

#################

import numpy as np

from bokeh.plotting import *

N = 100

x1 = np.linspace(0, 4*np.pi, N)

y1 = np.sin(x1)

x2 = np.linspace(0, 10, N)

y2 = np.exp(x2)

output_file(‘out1.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x1, y1, legend=“sin(x)”)

save()

output_file(‘out2.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x2, y2, legend=“exp(x)”)

save()

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/e18d1e50-1a83-4f78-a604-b144175a285f%40continuum.io.

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

Bryan,

···

On Fri, Nov 7, 2014 at 7:44 PM, Mateusz Paprocki [email protected] wrote:

Hi,

I think this should be handled in PR #1345.

Mateusz

On Fri, Nov 7, 2014 at 6:38 PM, Kamel [email protected] wrote:

Hello,

The way figures get accumulated into html output files seems like a bug, unless I’m missing something.

In the example below, out1.html contains the first figure (the sine wave), but out2.html contains both figures.

I’d expect and I want out2.html to only contain the second figure.

What’s going on here? thanks.

This is because output_* (file, server, notebook) don’t reset the global state. They used to do this but this was changed at some point. As a workaround you should use reset_output() before second invocation of output_file(). I’m pretty sure the original behaviour will be restored in the upcoming version of bokeh (Bryan, please correct me if I’m wrong).

Mateusz

#################

import numpy as np

from bokeh.plotting import *

N = 100

x1 = np.linspace(0, 4*np.pi, N)

y1 = np.sin(x1)

x2 = np.linspace(0, 10, N)

y2 = np.exp(x2)

output_file(‘out1.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x1, y1, legend=“sin(x)”)

save()

output_file(‘out2.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x2, y2, legend=“exp(x)”)

save()

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/e18d1e50-1a83-4f78-a604-b144175a285f%40continuum.io.

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

Kamel,

#1345 was merged and it is available in our latest release… so, with the new API, you will not have this problem.

Cheers.

Damian

···

On Friday, November 14, 2014 12:54:16 PM UTC-3, mateusz.paprocki wrote:

Bryan,

On Fri, Nov 7, 2014 at 7:44 PM, Mateusz Paprocki [email protected] wrote:

Hi,

On Fri, Nov 7, 2014 at 6:38 PM, Kamel [email protected] wrote:

Hello,

The way figures get accumulated into html output files seems like a bug, unless I’m missing something.

In the example below, out1.html contains the first figure (the sine wave), but out2.html contains both figures.

I’d expect and I want out2.html to only contain the second figure.

What’s going on here? thanks.

This is because output_* (file, server, notebook) don’t reset the global state. They used to do this but this was changed at some point. As a workaround you should use reset_output() before second invocation of output_file(). I’m pretty sure the original behaviour will be restored in the upcoming version of bokeh (Bryan, please correct me if I’m wrong).

I think this should be handled in PR #1345.

Mateusz

Mateusz

#################

import numpy as np

from bokeh.plotting import *

N = 100

x1 = np.linspace(0, 4*np.pi, N)

y1 = np.sin(x1)

x2 = np.linspace(0, 10, N)

y2 = np.exp(x2)

output_file(‘out1.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x1, y1, legend=“sin(x)”)

save()

output_file(‘out2.html’)

figure(tools=“pan,wheel_zoom,box_zoom,reset,previewsave”)

line(x2, y2, legend=“exp(x)”)

save()

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/e18d1e50-1a83-4f78-a604-b144175a285f%40continuum.io.

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