The plotting API

Hi,

I am going slowly through the taylor_server.py example with the idea of fully understanding each step and being able to explain it to my work colleagues. A few things during this reading still confuse me a bit.

Q1. The first one is that, in contrast to other examples such as legend.py from the Gallery, the app taylor_server.py uses the following plotting primitives for rendering multiple line plots on the same “plot”:

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“fy”, line_color=“blue”, line_width=2)

line_f_glyph = plot.add_glyph(source, line_f)

plot.add_layout(line_f_glyph)

which is very different from:

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", )

Why is that? Is the former what Bokeh used to call the low-level interface? If so, could taylor_server.py be rewritten, in principle, using the secondt and higher-level API?

Q2: What exactly is the difference between a document and a session? Can the same bokeh-server instance run multiple sessions and documents?

Q3: In the call shown below part of taylor_server.py

Inline image 1

can I tell Bokeh to use a specific sub-URL (e.g. http://localhost:5006/<whatever_name_I_choose>)?

Thanks again for all your help,

Josh

Hi,

···

On Tue, Dec 16, 2014 at 3:26 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am going slowly through the taylor_server.py example with the idea of fully understanding each step and being able to explain it to my work colleagues. A few things during this reading still confuse me a bit.

Q1. The first one is that, in contrast to other examples such as legend.py from the Gallery, the app taylor_server.py uses the following plotting primitives for rendering multiple line plots on the same “plot”:

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“fy”, line_color=“blue”, line_width=2)

line_f_glyph = plot.add_glyph(source, line_f)

plot.add_layout(line_f_glyph)

btw. The last line (add_layout()) shouldn’t be there. The example needs a fix.

which is very different from:

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", )

Why is that? Is the former what Bokeh used to call the low-level interface? If so, could taylor_server.py be rewritten, in principle, using the secondt and higher-level API?

taylor example is written using the low-level API, but it’s perfectly possible to reproduce this example with plotting API. Knowing the low-level API is beneficial, because plotting API generates an AST using the low-level API, so if you want to make some serious customisation of your plots, then you will be doing this on the lower level. For educational reason, there should have been a version of taylor example using the plotting API as well.

Q2: What exactly is the difference between a document and a session? Can the same bokeh-server instance run multiple sessions and documents?

Document is basically a container of plots and other models (see the low-level API). Session allows to talk to bokeh-server. You can see this nicely in examples/glyphs. Examples requiring a server use both, other use only Document. You can connect multiple sessions to a server. In fact, you can have a multi-user bokeh-server.

Q3: In the call shown below part of taylor_server.py

can I tell Bokeh to use a specific sub-URL (e.g. http://localhost:5006/<whatever_name_I_choose>)?

I think you can’t, at least without using apps/applets (see examples/app).

Mateusz

Thanks again for all your help,

Josh

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/CAD4ivxUY8aBSZzZp%2B2B-gUhbKjCWgcu6K4Fi%3DgO-GDye4c2d-g%40mail.gmail.com.

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

I would add that a document is an in memory storage of plotting
objects - for example the file and notebook examples all store
objects on a document, and then dump that document to a
file/notebook

The server exampels also use the same docuemnt, but push the

document to the server instead. The only wierdness is that each
session is configured for a specific document. That’s what
session.use_doc does (it configures the conection to point to a
specific document, and loads that document from the server) Usually
you do not call use_doc directly, it is called by output_server.
You can create as many sessions as you want, however some of the
plotting code defaults to using the current session.

In practice, I don't think it is common or necessary for most

people to use multiple documents or sessions at the same time

···

On 12/16/2014 03:50 AM, Mateusz
Paprocki wrote:

Hi,

        On Tue, Dec 16, 2014 at 3:26 AM, Josh

Wasserstein [email protected]
wrote:

Hi,

I am going slowly through the taylor_server.py example with
the idea of fully understanding each step and being
able to explain it to my work colleagues. A few things
during this reading still confuse me a bit.

Q1. The first one is that, in contrast to
other examples such as legend.py from the Gallery, the
app taylor_server.py uses the
following plotting primitives for rendering multiple
line plots on the same “plot”:

              plot

=
Plot(x_range= xdr,
y_range= ydr,
plot_width=800 ,
plot_height=400)

              line_f

=
Line(x=“x” ,
y=“fy” ,
line_color=“blue” ,
line_width=2)

              line_f_glyph

=
plot.add_glyph(source, line_f)

plot.add_layout(line_f_glyph)

          btw. The last line (add_layout()) shouldn't be there.

The example needs a fix.

which is very different from:

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", )
              Why is that? Is the former what Bokeh used to call

the low-level interface? If so, could taylor_server.py be rewritten,
in principle, using the secondt and higher-level API?

          taylor example is written using the low-level API, but

it’s perfectly possible to reproduce this example with
plotting API. Knowing the low-level API is beneficial,
because plotting API generates an AST using the low-level
API, so if you want to make some serious customisation of
your plots, then you will be doing this on the lower
level. For educational reason, there should have been a
version of taylor example using the plotting API as well.

Q2: What exactly is the difference between
a document and a session? Can the same bokeh-server
instance run multiple sessions and documents?

          Document is basically a container of plots and other

models (see the low-level API). Session allows to talk to
bokeh-server. You can see this nicely in examples/glyphs.
Examples requiring a server use both, other use only
Document. You can connect multiple sessions to a server.
In fact, you can have a multi-user bokeh-server.

Q3: In the call shown below part of taylor_server.py

can I tell Bokeh to use a specific sub-URL (e.g. http://localhost:5006/<whatever_name_I_choose>)?

          I think you can't, at least without using apps/applets

(see examples/app).

Mateusz

Thanks again for all your help,

Josh

              --

              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/CAD4ivxUY8aBSZzZp%2B2B-gUhbKjCWgcu6K4Fi%3DgO-GDye4c2d-g%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD4ivxUY8aBSZzZp%2B2B-gUhbKjCWgcu6K4Fi%3DgO-GDye4c2d-g%40mail.gmail.com?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).

  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/CANFzp8hSBAsEyRadk6qonvTskN_W7CZNcz1-q9xWUF%2BV6Ue-YA%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANFzp8hSBAsEyRadk6qonvTskN_W7CZNcz1-q9xWUF%2BV6Ue-YA%40mail.gmail.com?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).