How to use Bokeh in an offline environment

Dear all:
I’m still new to Bokeh, I want to use Bokeh to plot some line charts, like this:

import numpy as np

from bokeh.plotting import figure, show, output_file, vplot

x = np.linspace(0, 4*np.pi, 100)

y = np.sin(x)

TOOLS = “pan,wheel_zoom,box_zoom,reset,save,box_select”

p1 = figure(title=“Legend Example”, tools=TOOLS)

p1.circle(x, y, legend=“sin(x)”)

p1.circle(x, 2y, legend="2sin(x)", color=“orange”)

p1.circle(x, 3y, legend="3sin(x)", color=“green”)

p2 = figure(title=“Another Legend Example”, tools=TOOLS)

p2.circle(x, y, legend=“sin(x)”)

p2.line(x, y, legend=“sin(x)”)

p2.line(x, 2y, legend="2sin(x)",

line_dash=(4, 4), line_color=“orange”, line_width=2)

p2.square(x, 3y, legend="3sin(x)", fill_color=None, line_color=“green”)

p2.line(x, 3y, legend="3sin(x)", line_color=“green”)

output_file(“legend.html”, title=“legend.py example”)

show(vplot(p1, p2)) # open a browser

``

and then I find the HTML file, which include

``

Because of 2 files, I can’t see the image in an offline environment.Could I make “bokeh-0.11.1.min.css” & “bokeh-0.11.1.min.js” in my local machine, and output files replace those 2 files to local files automatically.

If it’s feasible ,how can I achieve it.

Thanks in advance!

Shuai Yang

Hi Shuai,

The easiest way would be to pass

  mode="inline"

as a keyword argument to output_file. This will cause Bokeh JS and its CSS to be inlined in the generated HTML file. But note that the individual HTML files will also be larger. It is possible make the document use "local" copies as well, for that I'd refer you to

  http://bokeh.pydata.org/en/0.12.0/docs/reference/io.html#bokeh.io.output_file
  http://bokeh.pydata.org/en/0.12.0/docs/reference/resources.html#bokeh.resources.Resources

for more information.

Thanks,

Bryan

···

On Jul 18, 2016, at 10:48 AM, Shuai Yang <[email protected]> wrote:

Dear all:
       I'm still new to Bokeh, I want to use Bokeh to plot some line charts, like this:
import numpy as np

from bokeh.plotting import figure, show, output_file, vplot

x = np.linspace(0, 4*np.pi, 100)
y = np.sin(x)

TOOLS = "pan,wheel_zoom,box_zoom,reset,save,box_select"

p1 = figure(title="Legend Example", tools=TOOLS)

p1.circle(x, y, legend="sin(x)")
p1.circle(x, 2*y, legend="2*sin(x)", color="orange")
p1.circle(x, 3*y, legend="3*sin(x)", color="green")

p2 = figure(title="Another Legend Example", tools=TOOLS)

p2.circle(x, y, legend="sin(x)")
p2.line(x, y, legend="sin(x)")

p2.line(x, 2*y, legend="2*sin(x)",
        line_dash=(4, 4), line_color="orange", line_width=2)

p2.square(x, 3*y, legend="3*sin(x)", fill_color=None, line_color="green")
p2.line(x, 3*y, legend="3*sin(x)", line_color="green")

output_file("legend.html", title="legend.py example")

show(vplot(p1, p2)) # open a browser

and then I find the HTML file, which include
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-0.11.1.min.css" type="text/css" />
        
<script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-0.11.1.min.js"></script>

Because of 2 files, I can't see the image in an offline environment.Could I make "bokeh-0.11.1.min.css" & "bokeh-0.11.1.min.js" in my local machine, and output files replace those 2 files to local files automatically.
If it's feasible ,how can I achieve it.

Thanks in advance!

Shuai Yang

--
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/533d75a1-cf70-484e-b0d7-90a24f702edf%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks a lot for you fast reply, I will read the reference you mentioned carefully.

Shuai Yang

在 2016年7月18日星期一 UTC+8下午11:55:10,Bryan Van de ven写道:

···

Hi Shuai,

The easiest way would be to pass

    mode="inline"

as a keyword argument to output_file. This will cause Bokeh JS and its CSS to be inlined in the generated HTML file. But note that the individual HTML files will also be larger. It is possible make the document use “local” copies as well, for that I’d refer you to

    [http://bokeh.pydata.org/en/0.12.0/docs/reference/io.html#bokeh.io.output_file](http://bokeh.pydata.org/en/0.12.0/docs/reference/io.html#bokeh.io.output_file)

    [http://bokeh.pydata.org/en/0.12.0/docs/reference/resources.html#bokeh.resources.Resources](http://bokeh.pydata.org/en/0.12.0/docs/reference/resources.html#bokeh.resources.Resources)

for more information.

Thanks,

Bryan

On Jul 18, 2016, at 10:48 AM, Shuai Yang [email protected] wrote:

Dear all:

   I'm still new to Bokeh, I want to use Bokeh to plot some line charts, like this:

import numpy as np

from bokeh.plotting import figure, show, output_file, vplot

x = np.linspace(0, 4*np.pi, 100)

y = np.sin(x)

TOOLS = “pan,wheel_zoom,box_zoom,reset,save,box_select”

p1 = figure(title=“Legend Example”, tools=TOOLS)

p1.circle(x, y, legend=“sin(x)”)

p1.circle(x, 2y, legend="2sin(x)", color=“orange”)

p1.circle(x, 3y, legend="3sin(x)", color=“green”)

p2 = figure(title=“Another Legend Example”, tools=TOOLS)

p2.circle(x, y, legend=“sin(x)”)

p2.line(x, y, legend=“sin(x)”)

p2.line(x, 2y, legend="2sin(x)",

    line_dash=(4, 4), line_color="orange", line_width=2)

p2.square(x, 3y, legend="3sin(x)", fill_color=None, line_color=“green”)

p2.line(x, 3y, legend="3sin(x)", line_color=“green”)

output_file(“legend.html”, title=“legend.py example”)

show(vplot(p1, p2)) # open a browser

and then I find the HTML file, which include

Because of 2 files, I can’t see the image in an offline environment.Could I make “bokeh-0.11.1.min.css” & “bokeh-0.11.1.min.js” in my local machine, and output files replace those 2 files to local files automatically.
If it’s feasible ,how can I achieve it.

Thanks in advance!

Shuai Yang


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/533d75a1-cf70-484e-b0d7-90a24f702edf%40continuum.io.

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

Sorry for digging out this old thread but my question fits really well here. Due to a slow connection I want to load the bokeh.js + other js,css files from a local storage. How do I use the bokeh.resources.Resources to set the mode of the server?
I can’t find the default instance of resources where i should overwrite the .mode variable. And once I set it to relative, is this instruction only for the server or would the client browser look for these files in a different location?

Cheers.

···

On Tuesday, 19 July 2016 00:55:10 UTC+9, Bryan Van de ven wrote:

Hi Shuai,

The easiest way would be to pass

    mode="inline"

as a keyword argument to output_file. This will cause Bokeh JS and its CSS to be inlined in the generated HTML file. But note that the individual HTML files will also be larger. It is possible make the document use “local” copies as well, for that I’d refer you to

    [http://bokeh.pydata.org/en/0.12.0/docs/reference/io.html#bokeh.io.output_file](http://bokeh.pydata.org/en/0.12.0/docs/reference/io.html#bokeh.io.output_file)

    [http://bokeh.pydata.org/en/0.12.0/docs/reference/resources.html#bokeh.resources.Resources](http://bokeh.pydata.org/en/0.12.0/docs/reference/resources.html#bokeh.resources.Resources)

for more information.

Thanks,

Bryan

On Jul 18, 2016, at 10:48 AM, Shuai Yang [email protected] wrote:

Dear all:

   I'm still new to Bokeh, I want to use Bokeh to plot some line charts, like this:

import numpy as np

from bokeh.plotting import figure, show, output_file, vplot

x = np.linspace(0, 4*np.pi, 100)

y = np.sin(x)

TOOLS = “pan,wheel_zoom,box_zoom,reset,save,box_select”

p1 = figure(title=“Legend Example”, tools=TOOLS)

p1.circle(x, y, legend=“sin(x)”)

p1.circle(x, 2y, legend="2sin(x)", color=“orange”)

p1.circle(x, 3y, legend="3sin(x)", color=“green”)

p2 = figure(title=“Another Legend Example”, tools=TOOLS)

p2.circle(x, y, legend=“sin(x)”)

p2.line(x, y, legend=“sin(x)”)

p2.line(x, 2y, legend="2sin(x)",

    line_dash=(4, 4), line_color="orange", line_width=2)

p2.square(x, 3y, legend="3sin(x)", fill_color=None, line_color=“green”)

p2.line(x, 3y, legend="3sin(x)", line_color=“green”)

output_file(“legend.html”, title=“legend.py example”)

show(vplot(p1, p2)) # open a browser

and then I find the HTML file, which include

Because of 2 files, I can’t see the image in an offline environment.Could I make “bokeh-0.11.1.min.css” & “bokeh-0.11.1.min.js” in my local machine, and output files replace those 2 files to local files automatically.
If it’s feasible ,how can I achieve it.

Thanks in advance!

Shuai Yang


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/533d75a1-cf70-484e-b0d7-90a24f702edf%40continuum.io.

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

Hi,

···

On Wed, Aug 30, 2017 at 1:44 PM, Colin [email protected] wrote:

Sorry for digging out this old thread but my question fits really well here. Due to a slow connection I want to load the bokeh.js + other js,css files from a local storage. How do I use the bokeh.resources.Resources to set the mode of the server?
I can’t find the default instance of resources where i should overwrite the .mode variable. And once I set it to relative, is this instruction only for the server or would the client browser look for these files in a different location?

from bokeh.resources import Resources

res = Resources(mode=“server”, root_url=“http://…”) # root_url necessary only if using non standard server configuration (e.g. custom port)

If you are going to work only with standalone plots and use server as static resource provider, then run python -m bokeh static (instead of serve).

Mateusz

Cheers.

On Tuesday, 19 July 2016 00:55:10 UTC+9, Bryan Van de ven wrote:

Hi Shuai,

The easiest way would be to pass

    mode="inline"

as a keyword argument to output_file. This will cause Bokeh JS and its CSS to be inlined in the generated HTML file. But note that the individual HTML files will also be larger. It is possible make the document use “local” copies as well, for that I’d refer you to

    [http://bokeh.pydata.org/en/0.12.0/docs/reference/io.html#bokeh.io.output_file](http://bokeh.pydata.org/en/0.12.0/docs/reference/io.html#bokeh.io.output_file)

    [http://bokeh.pydata.org/en/0.12.0/docs/reference/resources.html#bokeh.resources.Resources](http://bokeh.pydata.org/en/0.12.0/docs/reference/resources.html#bokeh.resources.Resources)

for more information.

Thanks,

Bryan

On Jul 18, 2016, at 10:48 AM, Shuai Yang [email protected] wrote:

Dear all:

   I'm still new to Bokeh, I want to use Bokeh to plot some line charts, like this:

import numpy as np

from bokeh.plotting import figure, show, output_file, vplot

x = np.linspace(0, 4*np.pi, 100)

y = np.sin(x)

TOOLS = “pan,wheel_zoom,box_zoom,reset,save,box_select”

p1 = figure(title=“Legend Example”, tools=TOOLS)

p1.circle(x, y, legend=“sin(x)”)

p1.circle(x, 2y, legend="2sin(x)", color=“orange”)

p1.circle(x, 3y, legend="3sin(x)", color=“green”)

p2 = figure(title=“Another Legend Example”, tools=TOOLS)

p2.circle(x, y, legend=“sin(x)”)

p2.line(x, y, legend=“sin(x)”)

p2.line(x, 2y, legend="2sin(x)",

    line_dash=(4, 4), line_color="orange", line_width=2)

p2.square(x, 3y, legend="3sin(x)", fill_color=None, line_color=“green”)

p2.line(x, 3y, legend="3sin(x)", line_color=“green”)

output_file(“legend.html”, title=“legend.py example”)

show(vplot(p1, p2)) # open a browser

and then I find the HTML file, which include

Because of 2 files, I can’t see the image in an offline environment.Could I make “bokeh-0.11.1.min.css” & “bokeh-0.11.1.min.js” in my local machine, and output files replace those 2 files to local files automatically.
If it’s feasible ,how can I achieve it.

Thanks in advance!

Shuai Yang


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/533d75a1-cf70-484e-b0d7-90a24f702edf%40continuum.io.

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

This correspondence (including any attachments) is for the intended recipient(s) only. It may contain confidential or privileged information or both. No confidentiality or privilege is waived or lost by any mis-transmission. If you receive this correspondence by mistake, please contact the sender immediately, delete this correspondence (and all attachments) and destroy any hard copies. You must not use, disclose, copy, distribute or rely on any part of this correspondence (including any attachments) if you are not the intended recipient(s).本メッセージに記載および添付されている情報(以下、総称して「本情報」といいます。)は、本来の受信者による使用のみを意図しています。誤送信等により本情報を取得された場合でも、本情報に係る秘密、または法律上の秘匿特権が失われるものではありません。本電子メールを受取られた方が、本来の受信者ではない場合には、本情報及びそのコピーすべてを削除・破棄し、本電子メールが誤って届いた旨を発信者宛てにご通知下さいますようお願いします。本情報の閲覧、発信または本情報に基づくいかなる行為も明確に禁止されていることをご了承ください。

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/891d1c4a-4b8f-40b7-ad78-f7a91b98d36d%40continuum.io.

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

Hi Mateusz,

this didn’t work because “res” is not used anywhere. Which variable should “res” replace in bokeh?
In any case, I could manage the index.html template file directly and replace the following to any link or file. But in this case one would have to keep track of the versions.

  •    {{ bokeh_css }}
    
  •    {{ bokeh_js }}
    
···
  •    <link
    
  •        href="http://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.css"
    
  •        rel="stylesheet" type="text/css">
    
  •    <link
    
  •        href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.6.min.css"
    
  •        rel="stylesheet" type="text/css">
    
  •    <script src="http://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.js"></script>
    
  •    <script src="http://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.6.min.js"></script>
    

Colin

On Wednesday, 30 August 2017 22:33:11 UTC+9, mateusz.paprocki wrote:

Hi,

On Wed, Aug 30, 2017 at 1:44 PM, Colin [email protected] wrote:

Sorry for digging out this old thread but my question fits really well here. Due to a slow connection I want to load the bokeh.js + other js,css files from a local storage. How do I use the bokeh.resources.Resources to set the mode of the server?
I can’t find the default instance of resources where i should overwrite the .mode variable. And once I set it to relative, is this instruction only for the server or would the client browser look for these files in a different location?

from bokeh.resources import Resources

res = Resources(mode=“server”, root_url=“http://…”) # root_url necessary only if using non standard server configuration (e.g. custom port)

If you are going to work only with standalone plots and use server as static resource provider, then run python -m bokeh static (instead of serve).

Mateusz

Hi,

···

On Mon, Sep 4, 2017 at 8:44 AM, Colin [email protected] wrote:

Hi Mateusz,

this didn’t work because “res” is not used anywhere. Which variable should “res” replace in bokeh?

it depends on your code, but if you use save() (bokeh.io) to save a plot, then you would say save(plot, resources=res).

Mateusz

In any case, I could manage the index.html template file directly and replace the following to any link or file. But in this case one would have to keep track of the versions.

  •    {{ bokeh_css }}
    
  •    {{ bokeh_js }}
    
  •    <link
    
  •        href="[http://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.css)"
    
  •        rel="stylesheet" type="text/css">
    
  •    <link
    
  •        href="[http://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.6.min.css](http://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.6.min.css)"
    
  •        rel="stylesheet" type="text/css">
    
  •    <script src="[http://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.12.6.min.js)"></script>
    
  •    <script src="[http://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.6.min.js](http://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.6.min.js)"></script>
    

Colin

On Wednesday, 30 August 2017 22:33:11 UTC+9, mateusz.paprocki wrote:

Hi,

On Wed, Aug 30, 2017 at 1:44 PM, Colin [email protected] wrote:

Sorry for digging out this old thread but my question fits really well here. Due to a slow connection I want to load the bokeh.js + other js,css files from a local storage. How do I use the bokeh.resources.Resources to set the mode of the server?
I can’t find the default instance of resources where i should overwrite the .mode variable. And once I set it to relative, is this instruction only for the server or would the client browser look for these files in a different location?

from bokeh.resources import Resources

res = Resources(mode=“server”, root_url=“http://…”) # root_url necessary only if using non standard server configuration (e.g. custom port)

If you are going to work only with standalone plots and use server as static resource provider, then run python -m bokeh static (instead of serve).

Mateusz

This correspondence (including any attachments) is for the intended recipient(s) only. It may contain confidential or privileged information or both. No confidentiality or privilege is waived or lost by any mis-transmission. If you receive this correspondence by mistake, please contact the sender immediately, delete this correspondence (and all attachments) and destroy any hard copies. You must not use, disclose, copy, distribute or rely on any part of this correspondence (including any attachments) if you are not the intended recipient(s).本メッセージに記載および添付されている情報(以下、総称して「本情報」といいます。)は、本来の受信者による使用のみを意図しています。誤送信等により本情報を取得された場合でも、本情報に係る秘密、または法律上の秘匿特権が失われるものではありません。本電子メールを受取られた方が、本来の受信者ではない場合には、本情報及びそのコピーすべてを削除・破棄し、本電子メールが誤って届いた旨を発信者宛てにご通知下さいますようお願いします。本情報の閲覧、発信または本情報に基づくいかなる行為も明確に禁止されていることをご了承ください。

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/8e1731d2-edf7-40dd-b713-90d5f7589afd%40continuum.io.

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