print a number in bokeh app

Hi,

Is there any way to show a output number with bokeh app?

For example, I would like to see the calculated results with figures

import numpy as np
from bokeh.plotting import output_file, figure, show

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

output_file(“legend_labels.html”)

p = figure()

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

t=30

print(t)
show(p)
I am using Bokeh 0.12.6 with python 3.6

Thank you in advance!!!

with best regards,

Moshiour

Hi,

I wasn’t quite sure what you were after here, but if it’s displaying the y values of the plotted points, the changes to your example shown below should help. Or, if you’re after a text box to put below your plot, you’ll need a widget: see here - the Div widget should do the job.

Hope that helps,
Marcus.

import numpy as np
from bokeh.plotting import output_file, figure, show
from bokeh.models import LabelSet
from bokeh.models.sources import ColumnDataSource

x = np.linspace(0, 4*np.pi, 100)
y = np.sin(x)
t = [’{:.2f}’.format(ye) for ye in y]
src = ColumnDataSource(data=dict(x=x, y=y, t=t))

l = LabelSet(x=‘x’, y=‘y’, text=‘t’, source=src)

p = figure()

p.circle(‘x’, ‘y’, source=src, legend=“sin(x)”)
p.add_layout(l)

output_file(“legend_labels.html”)

show(p)

``

Hi,

Thanks a lot for suggestions and got help.

best regards,

Moshiour

···

On Thu, Jul 6, 2017 at 6:20 PM, Marcus Donnelly [email protected] wrote:

Hi,

I wasn’t quite sure what you were after here, but if it’s displaying the y values of the plotted points, the changes to your example shown below should help. Or, if you’re after a text box to put below your plot, you’ll need a widget: see here - the Div widget should do the job.

Hope that helps,
Marcus.

import numpy as np
from bokeh.plotting import output_file, figure, show
from bokeh.models import LabelSet
from bokeh.models.sources import ColumnDataSource

x = np.linspace(0, 4*np.pi, 100)
y = np.sin(x)
t = [‘{:.2f}’.format(ye) for ye in y]
src = ColumnDataSource(data=dict(x=x, y=y, t=t))

l = LabelSet(x=‘x’, y=‘y’, text=‘t’, source=src)

p = figure()

p.circle(‘x’, ‘y’, source=src, legend=“sin(x)”)
p.add_layout(l)

output_file(“legend_labels.html”)

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 [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/3a5d1241-9031-4510-a225-5fa7f33dd136%40continuum.io.

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

Moshiour
Stockholm, Sweden

phone(ISD):0046700920057