Refresh browser display via booked server

Hi,

I have a simple code which plots on the browser (attached below). I have two questions. The first is how do I refresh this plot? That is if I rerun the python code that I use to plot the graph is there a way I can automatically delete the old plot on the browser? Right now it just creates a second identical plot on the browser.

The second question is, I want to introduce a second plot to appear on the browser mid way through the program (see the last 4 commented lines on the code below). This does not produce a plot on the browser. I know that IPython.display.clear_output(True) will not work on the browser (its there because it works on the python notebook when outputting to the notebook). Is there any function which works the same way for the browser?

Thanks,

Charith

########## CODE BLOCK 1 #############

def make_plot(x,y):

source = ColumnDataSource(data=dict(x=x, y=y))

p = figure(tools=“save, resize”,

background_fill_color="#E8DDCB", height=200, width=200)

p.circle(x=‘x’, y=‘y’, size=20, color=“navy”, alpha=0.5, source=source)

return p, source

from bokeh.models import ColumnDataSource, Range1d

from bokeh.plotting import figure, curdoc

from bokeh.layouts import Row

from bokeh.io import push_notebook

from bokeh.plotting import show, figure, curdoc, output_server

from bokeh.client import push_session, pull_session

import IPython.display

session = push_session(curdoc())

x = [1, 2, 3, 4, 5]

y = [6, 7, 2, 4, 5]

p1, source = make_plot(x,y)

session.show(Row(p1))

############### CODE BLOCK 2 ###################

x = [4, 2, 3, 3, 6]

y = [3, 7, 1, 3, 4]

p2, source2 = make_plot(x,y)

IPython.display.clear_output(True)

show(Row(p1,p2))

session.show(Row(p1,p2))

push_notebook()

I won't say that getting ahold of a specific browsers session and updating it from different processes at different times is impossible, but it is:

* very uncommon
* fairly advanced

So before digging into that rabbit hole, I think it's worth investigating if that's truly the best approach for whatever it is you are trying to do. Can you describe what you are trying to accomplish in more higher level, user-oriented description (i.e. without reference to specific technology)?

Thanks,

Bryan

···

On Oct 26, 2016, at 4:46 PM, Charith Peris <[email protected]> wrote:

Hi,

I have a simple code which plots on the browser (attached below). I have two questions. The first is how do I refresh this plot? That is if I rerun the python code that I use to plot the graph is there a way I can automatically delete the old plot on the browser? Right now it just creates a second identical plot on the browser.

The second question is, I want to introduce a second plot to appear on the browser mid way through the program (see the last 4 commented lines on the code below). This does not produce a plot on the browser. I know that IPython.display.clear_output(True) will not work on the browser (its there because it works on the python notebook when outputting to the notebook). Is there any function which works the same way for the browser?

Thanks,
Charith

########## CODE BLOCK 1 #############

def make_plot(x,y):
    
    source = ColumnDataSource(data=dict(x=x, y=y))
    p = figure(tools="save, resize",
                background_fill_color="#E8DDCB", height=200, width=200)
    p.circle(x='x', y='y', size=20, color="navy", alpha=0.5, source=source)

    return p, source

from bokeh.models import ColumnDataSource, Range1d
from bokeh.plotting import figure, curdoc
from bokeh.layouts import Row
from bokeh.io import push_notebook
from bokeh.plotting import show, figure, curdoc, output_server
from bokeh.client import push_session, pull_session
import IPython.display

session = push_session(curdoc())

x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

p1, source = make_plot(x,y)
session.show(Row(p1))

############### CODE BLOCK 2 ###################

x = [4, 2, 3, 3, 6]
y = [3, 7, 1, 3, 4]
p2, source2 = make_plot(x,y)
# IPython.display.clear_output(True)
# show(Row(p1,p2))
# session.show(Row(p1,p2))
# push_notebook()

--
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/b58f0382-28ee-4293-91d3-2b38d95cb892%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Yeah sure. So I am trying to build a visualization for a program which has probabilistic variables. i.e. as the program iterates, its list of output variables change. The visualization simply keeps track of the outputs of every variable created and plots, lets say a histogram. For a program in which outputs the same variables through its entire course, everything works fine with my present code. But whenever a new variable pops up, it is not able to handle it. Can you help?

···

On Tue, Nov 1, 2016 at 11:32 AM, Bryan Van de Ven [email protected] wrote:

I won’t say that getting ahold of a specific browsers session and updating it from different processes at different times is impossible, but it is:

  • very uncommon

  • fairly advanced

So before digging into that rabbit hole, I think it’s worth investigating if that’s truly the best approach for whatever it is you are trying to do. Can you describe what you are trying to accomplish in more higher level, user-oriented description (i.e. without reference to specific technology)?

Thanks,

Bryan

On Oct 26, 2016, at 4:46 PM, Charith Peris [email protected] wrote:

Hi,

I have a simple code which plots on the browser (attached below). I have two questions. The first is how do I refresh this plot? That is if I rerun the python code that I use to plot the graph is there a way I can automatically delete the old plot on the browser? Right now it just creates a second identical plot on the browser.

The second question is, I want to introduce a second plot to appear on the browser mid way through the program (see the last 4 commented lines on the code below). This does not produce a plot on the browser. I know that IPython.display.clear_output(True) will not work on the browser (its there because it works on the python notebook when outputting to the notebook). Is there any function which works the same way for the browser?

Thanks,

Charith

########## CODE BLOCK 1 #############

def make_plot(x,y):

source = ColumnDataSource(data=dict(x=x, y=y))
p = figure(tools="save, resize",
            background_fill_color="#E8DDCB", height=200, width=200)
p.circle(x='x', y='y', size=20, color="navy", alpha=0.5, source=source)
return p, source

from bokeh.models import ColumnDataSource, Range1d

from bokeh.plotting import figure, curdoc

from bokeh.layouts import Row

from bokeh.io import push_notebook

from bokeh.plotting import show, figure, curdoc, output_server

from bokeh.client import push_session, pull_session

import IPython.display

session = push_session(curdoc())

x = [1, 2, 3, 4, 5]

y = [6, 7, 2, 4, 5]

p1, source = make_plot(x,y)

session.show(Row(p1))

############### CODE BLOCK 2 ###################

x = [4, 2, 3, 3, 6]

y = [3, 7, 1, 3, 4]

p2, source2 = make_plot(x,y)

IPython.display.clear_output(True)

show(Row(p1,p2))

session.show(Row(p1,p2))

push_notebook()

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/b58f0382-28ee-4293-91d3-2b38d95cb892%40continuum.io.

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

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/10FBE04E-237B-475F-99D2-3BDD172DFDE7%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

This does not seem like it should need those advanced techniques, but it's hard to provide specific guidance without seeing what you have tried. Can you provide a complete, pared-down example of what you've tried to do, that didn't work?

Thanks,

Bryan

···

On Nov 7, 2016, at 2:42 PM, Charith Peris <[email protected]> wrote:

Yeah sure. So I am trying to build a visualization for a program which has probabilistic variables. i.e. as the program iterates, its list of output variables change. The visualization simply keeps track of the outputs of every variable created and plots, lets say a histogram. For a program in which outputs the same variables through its entire course, everything works fine with my present code. But whenever a new variable pops up, it is not able to handle it. Can you help?

On Tue, Nov 1, 2016 at 11:32 AM, Bryan Van de Ven <[email protected]> wrote:
I won't say that getting ahold of a specific browsers session and updating it from different processes at different times is impossible, but it is:

* very uncommon
* fairly advanced

So before digging into that rabbit hole, I think it's worth investigating if that's truly the best approach for whatever it is you are trying to do. Can you describe what you are trying to accomplish in more higher level, user-oriented description (i.e. without reference to specific technology)?

Thanks,

Bryan

> On Oct 26, 2016, at 4:46 PM, Charith Peris <[email protected]> wrote:
>
> Hi,
>
> I have a simple code which plots on the browser (attached below). I have two questions. The first is how do I refresh this plot? That is if I rerun the python code that I use to plot the graph is there a way I can automatically delete the old plot on the browser? Right now it just creates a second identical plot on the browser.
>
> The second question is, I want to introduce a second plot to appear on the browser mid way through the program (see the last 4 commented lines on the code below). This does not produce a plot on the browser. I know that IPython.display.clear_output(True) will not work on the browser (its there because it works on the python notebook when outputting to the notebook). Is there any function which works the same way for the browser?
>
> Thanks,
> Charith
>
>
>
> ########## CODE BLOCK 1 #############
>
> def make_plot(x,y):
>
> source = ColumnDataSource(data=dict(x=x, y=y))
> p = figure(tools="save, resize",
> background_fill_color="#E8DDCB", height=200, width=200)
> p.circle(x='x', y='y', size=20, color="navy", alpha=0.5, source=source)
>
> return p, source
>
> from bokeh.models import ColumnDataSource, Range1d
> from bokeh.plotting import figure, curdoc
> from bokeh.layouts import Row
> from bokeh.io import push_notebook
> from bokeh.plotting import show, figure, curdoc, output_server
> from bokeh.client import push_session, pull_session
> import IPython.display
>
> session = push_session(curdoc())
>
> x = [1, 2, 3, 4, 5]
> y = [6, 7, 2, 4, 5]
>
> p1, source = make_plot(x,y)
> session.show(Row(p1))
>
> ############### CODE BLOCK 2 ###################
>
> x = [4, 2, 3, 3, 6]
> y = [3, 7, 1, 3, 4]
> p2, source2 = make_plot(x,y)
> # IPython.display.clear_output(True)
> # show(Row(p1,p2))
> # session.show(Row(p1,p2))
> # push_notebook()
>
> --
> 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/b58f0382-28ee-4293-91d3-2b38d95cb892%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
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/10FBE04E-237B-475F-99D2-3BDD172DFDE7%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
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/CADRy0UKucTNNwMFZGMOFOsDfA-G7-4p0La8%3D9LbBQGdULKqoaQ%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.