%matplotlib inline
import pandas as pd
import matplotlib.pylab as plt
df = pd.read_csv('data/p_20130101_avg_dist.csv')
plt.scatter(df.building_block_int_dis_tbl_bulkdens, df.avg_pickup_dist_feet) #, s=df.col3)
<matplotlib.collections.PathCollection at 0x10e9d6590>
#from http://stackoverflow.com/questions/7714677/r-scatterplot-with-too-many-points
import numpy as np
import matplotlib.pyplot as plt
# N = 10000
# mean = [0, 0]
# cov = [[2, 2], [0, 2]]
# x,y = np.random.multivariate_normal(mean, cov, N).T
x = df.building_block_int_dis_tbl_bulkdens
y = df.avg_pickup_dist_feet
plt.xlabel('building_block_int_dis_tbl_bulkdens')
plt.ylabel('avg_pickup_dist_feet')
plt.scatter(x, y, s=70, alpha=0.03)
plt.ylim((0, 50))
plt.xlim((0, 40))
plt.show()
import pandas as pd
import numpy as np
x = df.building_block_int_dis_tbl_bulkdens
y = df.avg_pickup_dist_feet
regression = np.polyfit(x, y, 1)
import numpy as np
from bokeh.plotting import figure, output_file, show
# prepare some data
N = 4000
# x = np.random.random(size=N) * 100
# y = np.random.random(size=N) * 100
radii = np.random.random(size=N) * 1.5
radii = 1
colors = ["#%02x%02x%02x" % (r, g, 150) for r, g in zip(np.floor(50+2*x), np.floor(30+2*y))]
# output to static HTML file (with CDN resources)
output_file("color_scatter.html", title="color_scatter.py example", mode="cdn")
TOOLS="resize,crosshair,pan,wheel_zoom,box_zoom,reset,box_select,lasso_select"
# create a new plot with the tools above, and explicit ranges
p = figure(tools=TOOLS, x_range=(0,100), y_range=(0,100))
# add a circle renderer with vecorized colors and sizes
p.circle(x,y, radius=radii, fill_color=colors, fill_alpha=0.6, line_color=None)
# show the results
show(p)
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-3-ce0f2e992c70> in <module>() 1 import numpy as np 2 ----> 3 from bokeh.plotting import figure, output_file, show 4 5 # prepare some data ImportError: No module named bokeh.plotting
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
import numpy as np
from bokeh.plotting import *
N = 1000
# x = np.linspace(0, 10, N)
# y = np.linspace(0, 10, N)
xx, yy = np.meshgrid(x, y)
d = np.sin(xx)*np.cos(yy)
output_file("image.html", title="image.py example")
p = figure(x_range=[0, 100], y_range=[0, 100])
p.image(image=[d], x=[0], y=[0], dw=[10], dh=[10], palette="Spectral11")
show(p) # open a browser
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
#DON'T RUN, 1.3 GB FILE RESULTS.
#NEED TO INSTALL SEABORN
#NEED TO INSTALL SEABORN
#NEED TO INSTALL SEABORN
#NEED TO INSTALL SEABORN
#NEED TO INSTALL SEABORN
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as mplc
import matplotlib.pyplot as plt
from bokeh import mpl
from bokeh.plotting import show
# Generate the pandas dataframe
data = np.random.multivariate_normal([0, 0], [[1, 2], [2, 20]], size=100)
data = pd.DataFrame(data, columns=["X", "Y"])
mplc.rc("figure", figsize=(6, 6))
# Just plot seaborn kde
sns.kdeplot(data, cmap="BuGn_d")
plt.title("Seaborn kdeplot in bokeh.")
show(mpl.to_bokeh(name="kde"))
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-6-7f3b95f1a532> in <module>() 1 import numpy as np 2 import pandas as pd ----> 3 import seaborn as sns 4 import matplotlib as mplc 5 import matplotlib.pyplot as plt ImportError: No module named seaborn