☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

output_server() with patches

Community Support
matsui.stephanie
matsui.stephanie

I’m having a problem plotting a simple example to Bokeh server. When I run this code without the server, the two patches get plotted correctly.

from bokeh.plotting import figure, show, output_server

from bokeh.models import ColumnDataSource

import pandas as pd

p = figure(plot_width=300, plot_height=300)

df = pd.DataFrame({‘x’:[[1,2,3,float(‘NaN’),4,5,6,5]], ‘y’:[[1,2,1,float(‘NaN’),4,5,5,4]] })

cds = ColumnDataSource(df)

a = p.patches(‘x’, ‘y’, source=cds)

show(p)

When I try to plot the exact same code using output_server(), the plot shows up as an empty plot. Why would this be happening?

from bokeh.plotting import figure, show, output_server

from bokeh.models import ColumnDataSource

import pandas as pd

p = figure(plot_width=300, plot_height=300)

df = pd.DataFrame({‘x’:[[1,2,3,float(‘NaN’),4,5,6,5]], ‘y’:[[1,2,1,float(‘NaN’),4,5,5,4]] })

cds = ColumnDataSource(df)

a = p.patches(‘x’, ‘y’, source=cds)

output_server()

show(p)

⌁   Link to post
Bryan
Bryan

Hi, I'm not sure offhand, but I should say that output_server is mostly a historical quirk, and it has a number of drawbacks (which is why we do not heavily or actively promote its use). I have just opened an issue to propose deprecating and removing it entirely:

  Deprecate output_server · Issue #5154 · bokeh/bokeh · GitHub

For all Bokeh server apps I strongly recommend first using "native apps", i.e., those that are run like:

  bokeh serve --show myapp.py

These are all of the examples located here:

  https://github.com/bokeh/bokeh/tree/master/examples/app

Alternatively, the next best way is to use bokeh.client and push_session, etc. Some example of that kind are here:

  https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/animated.py
  https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/line_animate.py
  https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/selection_histogram.py

Thanks,

Bryan

···

On Sep 13, 2016, at 8:22 AM, matsui.stephanie@gmail.com wrote:

I'm having a problem plotting a simple example to Bokeh server. When I run this code without the server, the two patches get plotted correctly.

from bokeh.plotting import figure, show, output_server
from bokeh.models import ColumnDataSource
import pandas as pd

p = figure(plot_width=300, plot_height=300)
df = pd.DataFrame({'x':[[1,2,3,float('NaN'),4,5,6,5]], 'y':[[1,2,1,float('NaN'),4,5,5,4]] })

cds = ColumnDataSource(df)
a = p.patches('x', 'y', source=cds)
show(p)

When I try to plot the exact same code using output_server(), the plot shows up as an empty plot. Why would this be happening?

from bokeh.plotting import figure, show, output_server
from bokeh.models import ColumnDataSource
import pandas as pd

p = figure(plot_width=300, plot_height=300)
df = pd.DataFrame({'x':[[1,2,3,float('NaN'),4,5,6,5]], 'y':[[1,2,1,float('NaN'),4,5,5,4]] })

cds = ColumnDataSource(df)
a = p.patches('x', 'y', source=cds)
output_server()
show(p)

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/8689cbe0-fed0-4417-9d39-944fac7fe6c1%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
matsui.stephanie
matsui.stephanie

Thanks for the quick reply, I really appreciate it! I got the code to work with the native apps method, but I had a followup question as well.

I tried the second method as well, using bokeh.client and push_session(), but I couldn’t get it to work with the original dataframe from my previous example.

This code correctly plots the patches:

from bokeh.client import push_session

from bokeh.plotting import figure, curdoc

from bokeh.models import ColumnDataSource

import pandas as pd

p = figure(plot_width=300, plot_height=300)

df = pd.DataFrame({‘x’:[[1,2,3],[4,5,6,5]], ‘y’:[[1,2,1],[4,5,5,4]] })

cds = ColumnDataSource(df)

a = p.patches(‘x’, ‘y’, source=cds)

session = push_session(curdoc())

session.show(p)

However, when the dataframe uses the float(‘NaN’) separator (as my first example does), the push_session() method displays the empty plot again. Below is the code that doesn’t work.

from bokeh.client import push_session

from bokeh.plotting import figure, curdoc

from bokeh.models import ColumnDataSource

import pandas as pd

p = figure(plot_width=300, plot_height=300)

df = pd.DataFrame({‘x’:[[1,2,3,float(‘NaN’),4,5,6,5]], ‘y’:[[1,2,1,float(‘NaN’),4,5,5,4]] })

cds = ColumnDataSource(df)

a = p.patches(‘x’, ‘y’, source=cds)

session = push_session(curdoc())

session.show(p)

I don’t quite understand why this happens. The only difference is the float(‘NaN’) part, which I’ve found only correctly works with native apps and the basic show() function.

···

On Tuesday, September 13, 2016 at 9:45:26 AM UTC-4, Bryan Van de ven wrote:

Hi, I’m not sure offhand, but I should say that output_server is mostly a historical quirk, and it has a number of drawbacks (which is why we do not heavily or actively promote its use). I have just opened an issue to propose deprecating and removing it entirely:

    [https://github.com/bokeh/bokeh/issues/5154](https://github.com/bokeh/bokeh/issues/5154)

For all Bokeh server apps I strongly recommend first using “native apps”, i.e., those that are run like:

    bokeh serve --show myapp.py

These are all of the examples located here:

    [https://github.com/bokeh/bokeh/tree/master/examples/app](https://github.com/bokeh/bokeh/tree/master/examples/app)

Alternatively, the next best way is to use bokeh.client and push_session, etc. Some example of that kind are here:

    [https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/animated.py](https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/animated.py)

    [https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/line_animate.py](https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/line_animate.py)

    [https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/selection_histogram.py](https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/selection_histogram.py)

Thanks,

Bryan

On Sep 13, 2016, at 8:22 AM, matsui.s...@gmail.com wrote:

I’m having a problem plotting a simple example to Bokeh server. When I run this code without the server, the two patches get plotted correctly.

from bokeh.plotting import figure, show, output_server

from bokeh.models import ColumnDataSource

import pandas as pd

p = figure(plot_width=300, plot_height=300)

df = pd.DataFrame({‘x’:[[1,2,3,float(‘NaN’),4,5,6,5]], ‘y’:[[1,2,1,float(‘NaN’),4,5,5,4]] })

cds = ColumnDataSource(df)

a = p.patches(‘x’, ‘y’, source=cds)

show(p)

When I try to plot the exact same code using output_server(), the plot shows up as an empty plot. Why would this be happening?

from bokeh.plotting import figure, show, output_server

from bokeh.models import ColumnDataSource

import pandas as pd

p = figure(plot_width=300, plot_height=300)

df = pd.DataFrame({‘x’:[[1,2,3,float(‘NaN’),4,5,6,5]], ‘y’:[[1,2,1,float(‘NaN’),4,5,5,4]] })

cds = ColumnDataSource(df)

a = p.patches(‘x’, ‘y’, source=cds)

output_server()

show(p)

–
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 bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/8689cbe0-fed0-4417-9d39-944fac7fe6c1%40continuum.io.

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

⌁   Link to post

End of archived discussion · Replies are disabled