Commit 35534c45 authored by Vikrant Rajan's avatar Vikrant Rajan
Browse files

Bokeh Motion Detection

parent c70d9a5c
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bokeh Plot</title>
<script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-1.4.0.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
</script>
</head>
<body>
<div class="bk-root" id="b03d2ed8-a7a1-499f-aa5f-c22c979ff227" data-root-id="1001"></div>
<script type="application/json" id="1282">
{"149cb75b-76f2-4300-b404-e01539db6719":{"roots":{"references":[{"attributes":{"mantissas":[1,2,5],"max_interval":500.0,"num_minor_ticks":0},"id":"1047","type":"AdaptiveTicker"},{"attributes":{"base":60,"mantissas":[1,2,5,10,15,20,30],"max_interval":1800000.0,"min_interval":1000.0,"num_minor_ticks":0},"id":"1048","type":"AdaptiveTicker"},{"attributes":{"days":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]},"id":"1050","type":"DaysTicker"},{"attributes":{"base":24,"mantissas":[1,2,4,6,8,12],"max_interval":43200000.0,"min_interval":3600000.0,"num_minor_ticks":0},"id":"1049","type":"AdaptiveTicker"},{"attributes":{"months":[0,1,2,3,4,5,6,7,8,9,10,11]},"id":"1054","type":"MonthsTicker"},{"attributes":{"months":[0,2,4,6,8,10]},"id":"1055","type":"MonthsTicker"},{"attributes":{"days":[1,4,7,10,13,16,19,22,25,28]},"id":"1051","type":"DaysTicker"},{"attributes":{"days":[1,15]},"id":"1053","type":"DaysTicker"},{"attributes":{"months":[0,6]},"id":"1057","type":"MonthsTicker"},{"attributes":{"formatter":{"id":"1043","type":"BasicTickFormatter"},"minor_tick_line_color":{"value":null},"ticker":{"id":"1018","type":"BasicTicker"}},"id":"1017","type":"LinearAxis"},{"attributes":{"days":[1,8,15,22]},"id":"1052","type":"DaysTicker"},{"attributes":{"desired_num_ticks":1},"id":"1018","type":"BasicTicker"},{"attributes":{},"id":"1058","type":"YearsTicker"},{"attributes":{},"id":"1008","type":"LinearScale"},{"attributes":{"ticker":{"id":"1013","type":"DatetimeTicker"}},"id":"1016","type":"Grid"},{"attributes":{"callback":null},"id":"1004","type":"DataRange1d"},{"attributes":{"months":[0,4,8]},"id":"1056","type":"MonthsTicker"},{"attributes":{"callback":null,"tooltips":[["Start: ","@Start"],["End: ","@End"]]},"id":"1035","type":"HoverTool"},{"attributes":{"dimension":1,"ticker":{"id":"1018","type":"BasicTicker"}},"id":"1021","type":"Grid"},{"attributes":{"overlay":{"id":"1061","type":"BoxAnnotation"}},"id":"1024","type":"BoxZoomTool"},{"attributes":{"num_minor_ticks":5,"tickers":[{"id":"1047","type":"AdaptiveTicker"},{"id":"1048","type":"AdaptiveTicker"},{"id":"1049","type":"AdaptiveTicker"},{"id":"1050","type":"DaysTicker"},{"id":"1051","type":"DaysTicker"},{"id":"1052","type":"DaysTicker"},{"id":"1053","type":"DaysTicker"},{"id":"1054","type":"MonthsTicker"},{"id":"1055","type":"MonthsTicker"},{"id":"1056","type":"MonthsTicker"},{"id":"1057","type":"MonthsTicker"},{"id":"1058","type":"YearsTicker"}]},"id":"1013","type":"DatetimeTicker"},{"attributes":{},"id":"1059","type":"UnionRenderers"},{"attributes":{},"id":"1010","type":"LinearScale"},{"attributes":{"bottom":{"value":0},"fill_alpha":{"value":0.1},"fill_color":{"value":"#1f77b4"},"left":{"field":"left"},"line_alpha":{"value":0.1},"line_color":{"value":"#1f77b4"},"right":{"field":"right"},"top":{"value":1}},"id":"1039","type":"Quad"},{"attributes":{},"id":"1060","type":"Selection"},{"attributes":{},"id":"1027","type":"HelpTool"},{"attributes":{"active_drag":"auto","active_inspect":"auto","active_multi":null,"active_scroll":"auto","active_tap":"auto","tools":[{"id":"1022","type":"PanTool"},{"id":"1023","type":"WheelZoomTool"},{"id":"1024","type":"BoxZoomTool"},{"id":"1025","type":"SaveTool"},{"id":"1026","type":"ResetTool"},{"id":"1027","type":"HelpTool"},{"id":"1035","type":"HoverTool"}]},"id":"1028","type":"Toolbar"},{"attributes":{"formatter":{"id":"1045","type":"DatetimeTickFormatter"},"ticker":{"id":"1013","type":"DatetimeTicker"}},"id":"1012","type":"DatetimeAxis"},{"attributes":{},"id":"1022","type":"PanTool"},{"attributes":{"text":"Motion Graph"},"id":"1002","type":"Title"},{"attributes":{"callback":null},"id":"1006","type":"DataRange1d"},{"attributes":{},"id":"1023","type":"WheelZoomTool"},{"attributes":{"below":[{"id":"1012","type":"DatetimeAxis"}],"center":[{"id":"1016","type":"Grid"},{"id":"1021","type":"Grid"}],"left":[{"id":"1017","type":"LinearAxis"}],"plot_height":300,"plot_width":1000,"renderers":[{"id":"1040","type":"GlyphRenderer"}],"title":{"id":"1002","type":"Title"},"toolbar":{"id":"1028","type":"Toolbar"},"x_range":{"id":"1004","type":"DataRange1d"},"x_scale":{"id":"1008","type":"LinearScale"},"y_range":{"id":"1006","type":"DataRange1d"},"y_scale":{"id":"1010","type":"LinearScale"}},"id":"1001","subtype":"Figure","type":"Plot"},{"attributes":{},"id":"1025","type":"SaveTool"},{"attributes":{},"id":"1026","type":"ResetTool"},{"attributes":{"callback":null,"data":{"left":{"__ndarray__":"5e5YM3P0dkLnGRg0c/R2Qg==","dtype":"float64","shape":[2]},"right":{"__ndarray__":"xbjoM3P0dkLhFpw1c/R2Qg==","dtype":"float64","shape":[2]}},"selected":{"id":"1060","type":"Selection"},"selection_policy":{"id":"1059","type":"UnionRenderers"}},"id":"1037","type":"ColumnDataSource"},{"attributes":{"bottom":{"value":0},"fill_color":{"value":"green"},"left":{"field":"left"},"line_color":{"value":"green"},"right":{"field":"right"},"top":{"value":1}},"id":"1038","type":"Quad"},{"attributes":{},"id":"1043","type":"BasicTickFormatter"},{"attributes":{"bottom_units":"screen","fill_alpha":{"value":0.5},"fill_color":{"value":"lightgrey"},"left_units":"screen","level":"overlay","line_alpha":{"value":1.0},"line_color":{"value":"black"},"line_dash":[4,4],"line_width":{"value":2},"render_mode":"css","right_units":"screen","top_units":"screen"},"id":"1061","type":"BoxAnnotation"},{"attributes":{"source":{"id":"1037","type":"ColumnDataSource"}},"id":"1041","type":"CDSView"},{"attributes":{},"id":"1045","type":"DatetimeTickFormatter"},{"attributes":{"data_source":{"id":"1037","type":"ColumnDataSource"},"glyph":{"id":"1038","type":"Quad"},"hover_glyph":null,"muted_glyph":null,"nonselection_glyph":{"id":"1039","type":"Quad"},"selection_glyph":null,"view":{"id":"1041","type":"CDSView"}},"id":"1040","type":"GlyphRenderer"}],"root_ids":["1001"]},"title":"Bokeh Application","version":"1.4.0"}}
</script>
<script type="text/javascript">
(function() {
var fn = function() {
Bokeh.safely(function() {
(function(root) {
function embed_document(root) {
var docs_json = document.getElementById('1282').textContent;
var render_items = [{"docid":"149cb75b-76f2-4300-b404-e01539db6719","roots":{"1001":"b03d2ed8-a7a1-499f-aa5f-c22c979ff227"}}];
root.Bokeh.embed.embed_items(docs_json, render_items);
}
if (root.Bokeh !== undefined) {
embed_document(root);
} else {
var attempts = 0;
var timer = setInterval(function(root) {
if (root.Bokeh !== undefined) {
clearInterval(timer);
embed_document(root);
} else {
attempts++;
if (attempts > 100) {
clearInterval(timer);
console.log("Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing");
}
}
}, 10, root)
}
})(window);
});
};
if (document.readyState != "loading") fn();
else document.addEventListener("DOMContentLoaded", fn);
})();
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bokeh Plot</title>
<script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-1.4.0.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
</script>
</head>
<body>
<div class="bk-root" id="c856ed81-fc51-4993-a543-b1953e0f27f1" data-root-id="1002"></div>
<script type="application/json" id="1283">
{"1e600da5-6854-4e5d-8c7a-fbc2592df22a":{"roots":{"references":[{"attributes":{"days":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]},"id":"1051","type":"DaysTicker"},{"attributes":{"mantissas":[1,2,5],"max_interval":500.0,"num_minor_ticks":0},"id":"1048","type":"AdaptiveTicker"},{"attributes":{"base":24,"mantissas":[1,2,4,6,8,12],"max_interval":43200000.0,"min_interval":3600000.0,"num_minor_ticks":0},"id":"1050","type":"AdaptiveTicker"},{"attributes":{"months":[0,2,4,6,8,10]},"id":"1056","type":"MonthsTicker"},{"attributes":{"days":[1,4,7,10,13,16,19,22,25,28]},"id":"1052","type":"DaysTicker"},{"attributes":{"months":[0,1,2,3,4,5,6,7,8,9,10,11]},"id":"1055","type":"MonthsTicker"},{"attributes":{"days":[1,15]},"id":"1054","type":"DaysTicker"},{"attributes":{"months":[0,6]},"id":"1058","type":"MonthsTicker"},{"attributes":{"days":[1,8,15,22]},"id":"1053","type":"DaysTicker"},{"attributes":{},"id":"1059","type":"YearsTicker"},{"attributes":{"formatter":{"id":"1047","type":"BasicTickFormatter"},"minor_tick_line_color":{"value":null},"ticker":{"id":"1019","type":"BasicTicker"}},"id":"1018","type":"LinearAxis"},{"attributes":{"months":[0,4,8]},"id":"1057","type":"MonthsTicker"},{"attributes":{"callback":null},"id":"1005","type":"DataRange1d"},{"attributes":{},"id":"1045","type":"DatetimeTickFormatter"},{"attributes":{"num_minor_ticks":5,"tickers":[{"id":"1048","type":"AdaptiveTicker"},{"id":"1049","type":"AdaptiveTicker"},{"id":"1050","type":"AdaptiveTicker"},{"id":"1051","type":"DaysTicker"},{"id":"1052","type":"DaysTicker"},{"id":"1053","type":"DaysTicker"},{"id":"1054","type":"DaysTicker"},{"id":"1055","type":"MonthsTicker"},{"id":"1056","type":"MonthsTicker"},{"id":"1057","type":"MonthsTicker"},{"id":"1058","type":"MonthsTicker"},{"id":"1059","type":"YearsTicker"}]},"id":"1014","type":"DatetimeTicker"},{"attributes":{"ticker":{"id":"1014","type":"DatetimeTicker"}},"id":"1017","type":"Grid"},{"attributes":{"desired_num_ticks":1},"id":"1019","type":"BasicTicker"},{"attributes":{"dimension":1,"ticker":{"id":"1019","type":"BasicTicker"}},"id":"1022","type":"Grid"},{"attributes":{},"id":"1011","type":"LinearScale"},{"attributes":{"overlay":{"id":"1060","type":"BoxAnnotation"}},"id":"1025","type":"BoxZoomTool"},{"attributes":{"bottom":{"value":0},"fill_color":{"value":"green"},"left":{"field":"Start"},"line_color":{"value":"green"},"right":{"field":"End"},"top":{"value":1}},"id":"1039","type":"Quad"},{"attributes":{"formatter":{"id":"1045","type":"DatetimeTickFormatter"},"ticker":{"id":"1014","type":"DatetimeTicker"}},"id":"1013","type":"DatetimeAxis"},{"attributes":{},"id":"1028","type":"HelpTool"},{"attributes":{"bottom_units":"screen","fill_alpha":{"value":0.5},"fill_color":{"value":"lightgrey"},"left_units":"screen","level":"overlay","line_alpha":{"value":1.0},"line_color":{"value":"black"},"line_dash":[4,4],"line_width":{"value":2},"render_mode":"css","right_units":"screen","top_units":"screen"},"id":"1060","type":"BoxAnnotation"},{"attributes":{},"id":"1009","type":"LinearScale"},{"attributes":{"active_drag":"auto","active_inspect":"auto","active_multi":null,"active_scroll":"auto","active_tap":"auto","tools":[{"id":"1023","type":"PanTool"},{"id":"1024","type":"WheelZoomTool"},{"id":"1025","type":"BoxZoomTool"},{"id":"1026","type":"SaveTool"},{"id":"1027","type":"ResetTool"},{"id":"1028","type":"HelpTool"},{"id":"1036","type":"HoverTool"}]},"id":"1029","type":"Toolbar"},{"attributes":{},"id":"1023","type":"PanTool"},{"attributes":{},"id":"1047","type":"BasicTickFormatter"},{"attributes":{"callback":null},"id":"1007","type":"DataRange1d"},{"attributes":{},"id":"1024","type":"WheelZoomTool"},{"attributes":{"text":"Motion Graph"},"id":"1003","type":"Title"},{"attributes":{"callback":null,"tooltips":[["Start","@Start_string"],["End","@End_string"]]},"id":"1036","type":"HoverTool"},{"attributes":{},"id":"1026","type":"SaveTool"},{"attributes":{},"id":"1027","type":"ResetTool"},{"attributes":{"base":60,"mantissas":[1,2,5,10,15,20,30],"max_interval":1800000.0,"min_interval":1000.0,"num_minor_ticks":0},"id":"1049","type":"AdaptiveTicker"},{"attributes":{"source":{"id":"1001","type":"ColumnDataSource"}},"id":"1042","type":"CDSView"},{"attributes":{"bottom":{"value":0},"fill_alpha":{"value":0.1},"fill_color":{"value":"#1f77b4"},"left":{"field":"Start"},"line_alpha":{"value":0.1},"line_color":{"value":"#1f77b4"},"right":{"field":"End"},"top":{"value":1}},"id":"1040","type":"Quad"},{"attributes":{"data_source":{"id":"1001","type":"ColumnDataSource"},"glyph":{"id":"1039","type":"Quad"},"hover_glyph":null,"muted_glyph":null,"nonselection_glyph":{"id":"1040","type":"Quad"},"selection_glyph":null,"view":{"id":"1042","type":"CDSView"}},"id":"1041","type":"GlyphRenderer"},{"attributes":{},"id":"1061","type":"UnionRenderers"},{"attributes":{"callback":null,"data":{"End":{"__ndarray__":"0xn4m3X0dkI=","dtype":"float64","shape":[1]},"End_string":["2019-12-27 12:34:21"],"Start":{"__ndarray__":"iasXm3X0dkI=","dtype":"float64","shape":[1]},"Start_string":["2019-12-27 12:34:18"],"index":[0]},"selected":{"id":"1062","type":"Selection"},"selection_policy":{"id":"1061","type":"UnionRenderers"}},"id":"1001","type":"ColumnDataSource"},{"attributes":{},"id":"1062","type":"Selection"},{"attributes":{"below":[{"id":"1013","type":"DatetimeAxis"}],"center":[{"id":"1017","type":"Grid"},{"id":"1022","type":"Grid"}],"left":[{"id":"1018","type":"LinearAxis"}],"plot_height":300,"plot_width":1000,"renderers":[{"id":"1041","type":"GlyphRenderer"}],"title":{"id":"1003","type":"Title"},"toolbar":{"id":"1029","type":"Toolbar"},"x_range":{"id":"1005","type":"DataRange1d"},"x_scale":{"id":"1009","type":"LinearScale"},"y_range":{"id":"1007","type":"DataRange1d"},"y_scale":{"id":"1011","type":"LinearScale"}},"id":"1002","subtype":"Figure","type":"Plot"}],"root_ids":["1002"]},"title":"Bokeh Application","version":"1.4.0"}}
</script>
<script type="text/javascript">
(function() {
var fn = function() {
Bokeh.safely(function() {
(function(root) {
function embed_document(root) {
var docs_json = document.getElementById('1283').textContent;
var render_items = [{"docid":"1e600da5-6854-4e5d-8c7a-fbc2592df22a","roots":{"1002":"c856ed81-fc51-4993-a543-b1953e0f27f1"}}];
root.Bokeh.embed.embed_items(docs_json, render_items);
}
if (root.Bokeh !== undefined) {
embed_document(root);
} else {
var attempts = 0;
var timer = setInterval(function(root) {
if (root.Bokeh !== undefined) {
clearInterval(timer);
embed_document(root);
} else {
attempts++;
if (attempts > 100) {
clearInterval(timer);
console.log("Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing");
}
}
}, 10, root)
}
})(window);
});
};
if (document.readyState != "loading") fn();
else document.addEventListener("DOMContentLoaded", fn);
})();
</script>
</body>
</html>
\ No newline at end of file
,Start,End
0,2019-12-27 12:34:18.106721,2019-12-27 12:34:21.697614
"""
MOTION DETECTION APPLICATION
"""
import cv2, time, pandas
from datetime import datetime
first_frame = None
status_list = [None, None]
times = []
df = pandas.DataFrame(columns=["Start", "End"])
video = cv2.VideoCapture(0)
while True:
check, frame = video.read()
# 0 = nothing is moving, 1 = motion detected
status = 0
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (21, 21), 0)
if first_frame is None:
first_frame = gray
continue
delta_frame = cv2.absdiff(first_frame, gray)
thresh_frame = cv2.threshold(delta_frame, 30, 255, cv2.THRESH_BINARY)[1]
thresh_frame = cv2.dilate(thresh_frame, None, iterations=2)
(cnts,__) = cv2.findContours(thresh_frame.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for contour in cnts:
# checking the area of the objects in camera
if cv2.contourArea(contour) < 10000:
continue
status = 1
(x, y, w, h) = cv2.boundingRect(contour)
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 3)
status_list.append(status)
status_list = status_list[-2:]
if status_list[-1] == 1 and status_list[-2] == 0:
times.append(datetime.now())
if status_list[-1] == 0 and status_list[-2] == 1:
times.append(datetime.now())
cv2.imshow("Gray Frame", gray)
cv2.imshow("Delta Frame",delta_frame)
cv2.imshow("Threshold Frame",thresh_frame)
cv2.imshow("Color Frame", frame)
key = cv2.waitKey(1)
if key == ord('q'):
if status == 1:
times.append(datetime.now())
break
print(status_list)
print(times)
for i in range(0, len(times), 2):
df = df.append({"Start":times[i], "End": times[i+1]}, ignore_index=True)
df.to_csv("Times.csv")
video.release()
cv2.destroyAllWindows
\ No newline at end of file
from capture import df
from bokeh.plotting import figure, show, output_file
from bokeh.models import HoverTool, ColumnDataSource
df["Start_string"] = df["Start"].dt.strftime("%Y-%m-%d %H:%M:%S")
df["End_string"] = df["End"].dt.strftime("%Y-%m-%d %H:%M:%S")
cds = ColumnDataSource(df)
p = figure(x_axis_type = "datetime", height = 300, width = 1000, title = "Motion Graph")
p.yaxis.minor_tick_line_color = None
p.ygrid[0].ticker.desired_num_ticks = 1
hover = HoverTool(tooltips = [("Start", "@Start_string"),("End", "@End_string")])
p.add_tools(hover)
q = p.quad(left="Start", right = "End", bottom = 0, top = 1, color = "green", source = cds)
output_file("Graph1.html")
show(p)
\ No newline at end of file
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# Making a basic Bokeh Line Graph\n",
"\n",
"from bokeh.plotting import figure\n",
"from bokeh.io import output_file, show\n",
"\n",
"# getting some data\n",
"x = [3, 4, 5]\n",
"y = [6, 2, 7]\n",
"\n",
"# creating an output file\n",
"output_file(\"datavisualization.html\")\n",
"\n",
"# creating a figure object\n",
"f = figure()\n",
"\n",
"# creating a line plot with ^ data above ^\n",
"f.line(x, y)\n",
"\n",
"show(f)\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"# Making a basic Bokeh Line Graph\n",
"\n",
"from bokeh.plotting import figure\n",
"from bokeh.io import output_file, show\n",
"import pandas\n",
"\n",
"# getting some data\n",
"df = pandas.read_csv(\"data.csv\")\n",
"x = df[\"x\"]\n",
"y = df[\"y\"]\n",
"\n",
"# creating an output file\n",
"output_file(\"csv_file.html\")\n",
"\n",
"# creating a figure object\n",
"f = figure()\n",
"\n",
"# creating a line plot with ^ data above ^\n",
"f.line(x, y)\n",
"\n",
"show(f)\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Making a basic Bokeh Line Graph\n",
"\n",
"from bokeh.plotting import figure\n",
"from bokeh.io import output_file, show\n",
"import pandas\n",
"\n",
"# getting some data\n",
"df = pandas.read_csv(\"http://pythonhow.com/data/bachelors.csv\")\n",
"x = df[\"Year\"]\n",
"y = df[\"Engineering\"]\n",
"\n",
"# creating an output file\n",
"output_file(\"csv_file_2.html\")\n",
"\n",
"# creating a figure object\n",
"f = figure()\n",
"\n",
"# creating a line plot with ^ data above ^\n",
"f.line(x, y)\n",
"\n",
"show(f)\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": true
},
"outputs": [
{
"ename": "AttributeError",
"evalue": "unexpected attribute 'logo' to Figure, possible attributes are above, align, aspect_ratio, aspect_scale, background, background_fill_alpha, background_fill_color, below, border_fill_alpha, border_fill_color, center, css_classes, disabled, extra_x_ranges, extra_y_ranges, frame_height, frame_width, height, height_policy, hidpi, inner_height, inner_width, js_event_callbacks, js_property_callbacks, left, lod_factor, lod_interval, lod_threshold, lod_timeout, margin, match_aspect, max_height, max_width, min_border, min_border_bottom, min_border_left, min_border_right, min_border_top, min_height, min_width, name, outer_height, outer_width, outline_line_alpha, outline_line_cap, outline_line_color, outline_line_dash, outline_line_dash_offset, outline_line_join, outline_line_width, output_backend, plot_height, plot_width, renderers, reset_policy, right, sizing_mode, subscribed_events, tags, title, title_location, toolbar, toolbar_location, toolbar_sticky, visible, width, width_policy, x_range, x_scale, y_range or y_scale",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-4-83d2c11ef81c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"Engineering\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0mp\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfigure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mplot_width\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m500\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mplot_height\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m400\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtools\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'pan'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlogo\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtitle\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"Cool Data\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bokeh/plotting/figure.py\u001b[0m in \u001b[0;36mfigure\u001b[0;34m(**kwargs)\u001b[0m\n\u001b[1;32m 1240\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1241\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mfigure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1242\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1243\u001b[0m \u001b[0mfigure\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mFigure\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__doc__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1244\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bokeh/plotting/figure.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, *arg, **kw)\u001b[0m\n\u001b[1;32m 151\u001b[0m \u001b[0mkw\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'title'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mTitle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtitle\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 152\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 153\u001b[0;31m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mFigure\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 154\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mx_range\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_get_range\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mopts\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mx_range\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bokeh/model.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 316\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"id\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 317\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 318\u001b[0;31m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mModel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 319\u001b[0m \u001b[0mdefault_theme\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_to_model\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 320\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bokeh/core/has_props.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, **properties)\u001b[0m\n\u001b[1;32m 251\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 252\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mproperties\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 253\u001b[0;31m \u001b[0msetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 254\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 255\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__setattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bokeh/core/has_props.py\u001b[0m in \u001b[0;36m__setattr__\u001b[0;34m(self, name, value)\u001b[0m\n\u001b[1;32m 285\u001b[0m \u001b[0mmatches\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtext\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mprops\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"possible\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 286\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 287\u001b[0;31m raise AttributeError(\"unexpected attribute '%s' to %s, %s attributes are %s\" %\n\u001b[0m\u001b[1;32m 288\u001b[0m (name, self.__class__.__name__, text, nice_join(matches)))\n\u001b[1;32m 289\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: unexpected attribute 'logo' to Figure, possible attributes are above, align, aspect_ratio, aspect_scale, background, background_fill_alpha, background_fill_color, below, border_fill_alpha, border_fill_color, center, css_classes, disabled, extra_x_ranges, extra_y_ranges, frame_height, frame_width, height, height_policy, hidpi, inner_height, inner_width, js_event_callbacks, js_property_callbacks, left, lod_factor, lod_interval, lod_threshold, lod_timeout, margin, match_aspect, max_height, max_width, min_border, min_border_bottom, min_border_left, min_border_right, min_border_top, min_height, min_width, name, outer_height, outer_width, outline_line_alpha, outline_line_cap, outline_line_color, outline_line_dash, outline_line_dash_offset, outline_line_join, outline_line_width, output_backend, plot_height, plot_width, renderers, reset_policy, right, sizing_mode, subscribed_events, tags, title, title_location, toolbar, toolbar_location, toolbar_sticky, visible, width, width_policy, x_range, x_scale, y_range or y_scale"
]
}
],
"source": [
"from bokeh.plotting import figure\n",
"from bokeh.io import output_file, show\n",
"import pandas\n",
"\n",
"# getting some data\n",
"df = pandas.read_csv(\"http://pythonhow.com/data/bachelors.csv\")\n",
"x = df[\"Year\"]\n",
"y = df[\"Engineering\"]\n",
" \n",
"p=figure(plot_width=500,plot_height=400, tools='pan',logo=None)\n",
" \n",
"p.title.text=\"Cool Data\"\n",
"p.title.text_color=\"Gray\"\n",
"p.title.text_font=\"times\"\n",
"p.title.text_font_style=\"bold\"\n",
"p.xaxis.minor_tick_line_color=None\n",
"p.yaxis.minor_tick_line_color=None\n",
"p.xaxis.axis_label=\"Date\"\n",
"p.yaxis.axis_label=\"Intensity\" \n",
" \n",
"p.line(x,y)\n",
"output_file(\"graph.html\")\n",
"show(p)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import pandas\n",
" \n",
"from bokeh.plotting import figure, output_file, show\n",
" \n",
"df=pandas.read_excel(\"http://pythonhow.com/data/verlegenhuken.xlsx\",sheet_name=0)\n",
"df[\"Temperature\"]=df[\"Temperature\"]/10\n",
"df[\"Pressure\"]=df[\"Pressure\"]/10\n",
" \n",
"p=figure(plot_width=500,plot_height=400,tools='pan')\n",
" \n",
"p.title.text=\"Temperature and Air Pressure\"\n",
"p.title.text_color=\"Gray\"\n",
"p.title.text_font=\"arial\"\n",
"p.title.text_font_style=\"bold\"\n",
"p.xaxis.minor_tick_line_color=None\n",
"p.yaxis.minor_tick_line_color=None\n",
"p.xaxis.axis_label=\"Temperature (°C)\"\n",
"p.yaxis.axis_label=\"Pressure (hPa)\" \n",
" \n",
"p.circle(df[\"Temperature\"],df[\"Pressure\"],size=0.5)\n",
"output_file(\"Weather.html\")\n",
"show(p)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"import pandas\n",
"from bokeh.plotting import figure, output_file, show\n",
"\n",
"df=pandas.read_csv(\"adbe.csv\",parse_dates=[\"Date\"])\n",
"\n",
"p=figure(width=500, height=250, x_axis_type=\"datetime\")\n",
"\n",
"p.line(df[\"Date\"], df[\"Close\"], color=\"Orange\", alpha = 0.5)\n",
"\n",
"output_file(\"Timeseries.html\")\n",
"show(p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
http://www.google.com/finance/historical?q=NASDAQ:ADBE&startdate=Jan+01%2C+2009&enddate=Aug+2%2C+2012&output=csv
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bokeh Plot</title>
<script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-1.4.0.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
</script>
</head>