This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import needed package | |
import pycodestyle | |
# Create a StyleGuide instance | |
style_checker = pycodestyle.StyleGuide() | |
# Run PEP 8 check on multiple files | |
result = style_checker.check_files(['nay_pep8.py', 'yay_pep8.py']) | |
# Print result of PEP 8 style check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.models import CategoricalColorMapper | |
mapper = CategoricalColorMapper(factors=['setosa', 'virginica', 'versicolor], palette=['red', 'green', 'blue']) | |
plot = figure(x_axis_label='petal_length', y_axis_label='sepal_length') | |
plot.circle('petal_length', 'sepal_length', size=10, source=source, color={'field': 'species', 'transform': mapper}= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot = figure(tools='box_select, lasso_select') | |
plot.circle(petal_length, sepal_length, selection_color='red', nonselect_fill_alpha=0.2, nonselection_fill_color='grey') | |
#to apport change to the visual appearance | |
from bokeh.models import HoverTool | |
#it doesn't display the tooltips and shows an horizontal line under the mouse position for the inspection | |
hover = HoverTool(tooltips=None, mode='hline') | |
plot = figure(tools[hover, 'crosshair']) | |
plot.circle(x, y, size=15, hover_color='red') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.models import ColumnDataSource | |
source = ColumnDataSource(data={'x': [1,2,3,4,5], 'y': [8,6,5,2,3]}) | |
#pass a python dict to the initializer, that should have string keys and two arrays of | |
#the SAME length | |
print(source.data) | |
from bokeh.sampledata.iris import flowers as df | |
column_from_dataframe = ColumnDataSource(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.io import output_file, show | |
from bokeh.plotting import figure | |
# Flowers is a Pandas Dataframe | |
from bokeh.sampledate.iris import flowers | |
plot = figure() | |
plot.circle(flowers['petal_length'], flowers['sepal_length'], size=10) | |
output_file('pandas.html') | |
show(plot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.io import output_file, show | |
from bokeh.plotting import figure | |
import numpy as np | |
x = np.linspace(0, 100, 1000) #one number every 100 till 1000 | |
y = np.sin(x) + np.random.random(1000) * 0.2 #random noise added to sinusoid | |
plot = figure() | |
plot.line(x,y) | |
output_file('numpy.html') | |
show(plot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.io import output_file | |
from bokeh.plotting import figure | |
xs = [ [1,1,2,2,], [2,2,4], [2,2,3,3] ] | |
ys = [ [2,5,5,2], [3,5,5], [2,3,4,2] ] | |
plot = figure() | |
plot.patches(xs, ys, fill_color= ['red', 'blue', 'green'], line_color='white') | |
output_file('patches.html') | |
show(plot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.io import output_file, show | |
from bokeh.plotting import figure | |
x = [1,2,3,4,5] | |
y = [8,6,5,2,3] | |
plot = figure() | |
plot.line(x, y, line_width=2) | |
#to use markers | |
plot.circle(x, y, fill_color='white', size=10) | |
output_file('line.html') | |
show(plot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.io import output_file, show | |
from bokeh.plotting import figure | |
plot = figure(x_axis_label='x axis', y_axis_label='y axis',plot_width=400, tools='pan,box_zoom') | |
plot.circle([1,2,3,4,5], [8,6,5,2,3]) #x and y coordinates lists | |
output_file('circle.html') | |
show(plot) #save and open to the browser | |
plot1 = figure() | |
plot1.circle(x=10, y=[2,5,8,12], size=[10,20,30,40]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
with open('filename.json', 'r') as f: | |
json_dict = json.load(f) | |
for key in json_dict: | |
print(key['attribute']) |