Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Jupyter notebook bokeh/bokeh.ipynb

Views: 263
Kernel: Python 3 (Anaconda 2021)

Bokeh inside Anaconda 2.4.1/Python 3.5

To see the published html, goto https://cloud.sagemath.com/20e4a191-73ea-4921-80e9-0a5d792fc511/raw/bokeh/bokeh.html

import sys sys.version
'3.9.7 (default, Sep 16 2021, 13:09:58) \n[GCC 7.5.0]'
import numpy as np print(np) np.__version__
<module 'numpy' from '/ext/anaconda2021.11/lib/python3.9/site-packages/numpy/__init__.py'>
'1.20.3'
import bokeh bokeh.__version__
'2.4.2'
from bokeh.io import output_notebook, show output_notebook()
Loading BokehJS ...
MIME type unknown not supported
from bokeh.plotting import figure import numpy as np x = np.linspace(0, 4*np.pi, 100) y = np.sin(x) plot = figure(title="Sine Function") plot.xaxis.axis_label='x' plot.yaxis.axis_label='amplitude' plot.line(x, y, line_color='blue', line_width=2, legend='sin(x)') plot.circle(x, 2*y, fill_color='red', line_color='black', fill_alpha=0.2, size=10, legend='2sin(x)') #line_dash is an aribrary length list of lengths #alternating in [color, blank, color, ...] plot.line(x, np.sin(2*x), line_color='green', line_dash=[10,5,2,5], line_width=2, legend='sin(2x)') show(plot)
BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead
MIME type unknown not supported
from bokeh.sampledata.iris import flowers flowers.head()
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
from bokeh.charts import Scatter plot = Scatter(flowers, x='petal_length', y='petal_width', color='species', legend='top_left', title='Flower Morphology') show(plot)
/projects/anaconda3/lib/python3.5/site-packages/bokeh/charts/_attributes.py:78: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....) df = df.sort(columns=columns)