Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bokeh example is incompatible with recent versions #4

Open
ostueker opened this issue May 4, 2017 · 0 comments
Open

Bokeh example is incompatible with recent versions #4

ostueker opened this issue May 4, 2017 · 0 comments

Comments

@ostueker
Copy link

ostueker commented May 4, 2017

The Bokeh example in chapter 7 (Analysis and Visualization) on page 173 is no longer compatible with current versions of Bokeh.

Below is the corrected example and a diff compared with the content of cell [9] in ch08-analysis-and-viz.ipynb:

import numpy as np
# import the Bokeh plotting tools
from bokeh import plotting as bp

# as in the matplotlib example, load decays.csv into a NumPy array
decaydata = np.loadtxt('data/decays.csv',delimiter=",",skiprows=1)

# provide handles for the x and y columns
time = decaydata[:,0]
decays = decaydata[:,1]

# define some output file metadata
bp.output_file("decays.html", title="Experiment 1 Radioactivity")

# create a figure with fun Internet-friendly features (optional)
f = bp.figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave",
              title="Decays", x_axis_label="Time (s)", y_axis_label="Decays (#)" )

# on that figure, create a line plot
f.line(time, decays, color='#1F78B4', legend='Decays per second' )

# additional customization to the figure can be specified separately
f.grid.grid_line_alpha=0.3

# open a browser
bp.show(f)
--- bokeh_old.py	2017-05-04 15:31:54.268924393 -0230
+++ bokeh_new.py	2017-05-04 15:31:02.076925327 -0230
@@ -13,15 +13,15 @@
 bp.output_file("decays.html", title="Experiment 1 Radioactivity")
 
 # create a figure with fun Internet-friendly features (optional)
-bp.figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave")
+f = bp.figure(tools="pan,wheel_zoom,box_zoom,reset,previewsave",
+              title="Decays", x_axis_label="Time (s)", y_axis_label="Decays (#)" )
 
 # on that figure, create a line plot
-bp.line(time, decays, x_axis_label="Time (s)", y_axis_label="Decays (#)",
-     color='#1F78B4', legend='Decays per second')
+f.line(time, decays, color='#1F78B4', legend='Decays per second' )
 
 # additional customization to the figure can be specified separately
-bp.curplot().title = "Decays"
-bp.grid().grid_line_alpha=0.3
+f.grid.grid_line_alpha=0.3
 
 # open a browser
-bp.show()
+bp.show(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant