Kernel: Python 3 (system-wide)
Testing Bokeh on CoCalc
In [9]:
import bokeh bokeh.__version__
Out[9]:
'2.4.2'
In [10]:
from bokeh.io import output_notebook output_notebook()
Out[10]:
MIME type unknown not supported
In [11]:
from bokeh.models import Div, RangeSlider, Spinner from bokeh.plotting import figure, show from bokeh.layouts import layout x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y = [4, 5, 5, 7, 2, 6, 4, 9, 1, 3] p = figure(x_range=(1, 9), width=500, height=250) points = p.circle(x=x, y=y, size=30, fill_color="#21a7df") div = Div( text=""" <p>Select the circle's size using this control element:</p> """, width=200, height=30, ) spinner = Spinner( title="Circle size", # a string to display above the widget low=0, # the lowest possible number to pick high=60, # the highest possible number to pick step=5, # the increments by which the number can be adjusted value=points.glyph.size, # the initial value to display in the widget width=200, # the width of the widget in pixels ) spinner.js_link("value", points.glyph, "size") range_slider = RangeSlider( title="Adjust x-axis range", # a title to display above the slider start=0, # set the minimum value for the slider end=10, # set the maximum value for the slider step=1, # increments for the slider value=(p.x_range.start, p.x_range.end), # initial values for slider ) range_slider.js_link("value", p.x_range, "start", attr_selector=0) range_slider.js_link("value", p.x_range, "end", attr_selector=1) layout = layout([ [div, spinner], [range_slider], [p], ]) show(layout)
Out[11]:
MIME type unknown not supported
In [12]:
from bokeh.plotting import figure, show # prepare some data x = [1, 2, 3, 4, 5] y = [6, 7, 2, 4, 5] # create new plot p = figure(title="Headline example") # add line renderer with a legend p.line(x, y, legend_label="Temp.", line_width=2) # change headline location to the left p.title_location = "left" # change headline text p.title.text = "Changing headline text example" # style the headline p.title.text_font_size = "25px" p.title.align = "right" p.title.background_fill_color = "darkgrey" p.title.text_color = "white" # show the results show(p)
Out[12]:
MIME type unknown not supported
In [13]:
import numpy as np from bokeh.plotting import figure, show N = 4000 x = np.random.random(size=N) * 100 y = np.random.random(size=N) * 100 radii = np.random.random(size=N) * 1.5 colors = np.array([ [r, g, 150] for r, g in zip(50 + 2*x, 30 + 2*y) ], dtype="uint8") TOOLS="hover,crosshair,pan,wheel_zoom,zoom_in,zoom_out,box_zoom,undo,redo,reset,tap,save,box_select,poly_select,lasso_select," p = figure(tools=TOOLS) p.scatter(x, y, radius=radii, fill_color=colors, fill_alpha=0.6, line_color=None) show(p)
Out[13]:
WARNING: Some output was deleted.
In [0]:
In [0]: