This serves as an example of how to add a zoomable feature to a plot using a "brush". By selecting a window width in the bottom graph, the top graph is redrawn with that window extent. For this data this may not be all that interesting, but in principle it is an interesting technique.
date | temp | |
---|---|---|
2011-04-11 03:00:00 | 9.5 | |
2011-04-11 04:00:00 | 9.5 | |
2011-04-11 05:00:00 | 9.5 | |
2011-04-11 06:00:00 | 9.5 | |
2011-04-11 07:00:00 | 9.75 | |
2011-04-11 08:00:00 | 10.25 | |
2011-04-11 09:00:00 | 10.75 | |
2011-04-11 10:00:00 | 11.4166666666667 | |
2011-04-11 11:00:00 | 12.4166666666667 |
date | North | West | SouthEast | Site4 | |
---|---|---|---|---|---|
2011-04-11 03:00:00 | 9.5 | 9.5 | NA | 9.5 | |
2011-04-11 04:00:00 | 9.5 | 9.583333333 | NA | 9.5 | |
2011-04-11 05:00:00 | 9.5 | 9.5 | NA | 9.5 | |
2011-04-11 06:00:00 | 9.5 | 9.5 | NA | 9.5 | |
2011-04-11 07:00:00 | 9.75 | 9.75 | NA | 9.5 | |
2011-04-11 08:00:00 | 10.25 | 10.66666667 | NA | 9.666666667 | |
2011-04-11 09:00:00 | 10.75 | 11.66666667 | NA | 10.75 | |
2011-04-11 10:00:00 | 11.41666667 | 12.91666667 | NA | 11.5 | |
2011-04-11 11:00:00 | 12.41666667 | 15.08333333 | NA | 12.83333333 |
date | SouthEast | West | North | Site4 | |
---|---|---|---|---|---|
04-11-11 03:00:00 | NA | 9.5 | 9.5 | 9.5 | |
04-11-11 04:00:00 | NA | 9.583333333 | 9.5 | 9.5 | |
04-11-11 05:00:00 | NA | 9.5 | 9.5 | 9.5 | |
04-11-11 06:00:00 | NA | 9.5 | 9.5 | 9.5 | |
04-11-11 07:00:00 | NA | 9.75 | 9.75 | 9.5 | |
04-11-11 08:00:00 | NA | 10.66666667 | 10.25 | 9.666666667 | |
04-11-11 09:00:00 | NA | 11.66666667 | 10.75 | 10.75 | |
04-11-11 10:00:00 | NA | 12.91666667 | 11.41666667 | 11.5 | |
04-11-11 11:00:00 | NA | 15.08333333 | 12.41666667 | 12.83333333 |
I'm playing with this code adapted largely from the very nice example from http://2011.12devsofxmas.co.uk/2012/01/data-visualisation/
The code remains a bit messy, as I am clearing out parts that I don't need and organizing the remaining code, so please bear with any slight disorganization.
This is best viewed by clicking the link to open this example in a new window so you can see the whole visualization.
date | Site3 | Site2 | Site1 | |
---|---|---|---|---|
04-11-11 03:48:00 | NA | NA | NA | |
04-11-11 03:58:00 | NA | NA | NA | |
04-11-11 04:08:00 | NA | NA | NA | |
04-11-11 04:18:00 | NA | NA | NA | |
04-11-11 04:28:00 | NA | NA | NA | |
04-11-11 04:38:00 | NA | NA | NA | |
04-11-11 04:48:00 | NA | 0 | 0 | |
04-11-11 04:58:00 | NA | 0 | 0 | |
04-11-11 05:08:00 | NA | -0.5 | 0 |
date,Site3,Site2,Site1 | |
09-01-11 00:03:00,NA,NA,NA | |
09-01-11 00:13:00,NA,NA,NA | |
09-01-11 00:23:00,NA,NA,NA | |
09-01-11 00:33:00,NA,NA,NA | |
09-01-11 00:43:00,NA,NA,NA | |
09-01-11 00:53:00,NA,NA,NA | |
09-01-11 01:03:00,0,-0.5,-0.5 | |
09-01-11 01:13:00,0,-0.5,-0.5 | |
09-01-11 01:23:00,0,-0.5,-0.5 |
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"> | |
<title>Data visualisation demo</title> | |
<style> | |
body | |
{ |
<!doctype HTML> | |
<meta charset = 'utf-8'> | |
<html> | |
<head> | |
<link rel='stylesheet' href='http://nvd3.org/src/nv.d3.css'> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' type='text/javascript'></script> | |
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script> | |
<script src='http://nvd3.org/nv.d3.js' type='text/javascript'></script> | |
<script src='http://nvd3.org/lib/fisheye.js' type='text/javascript'></script> |
Here is a dataset from data.sfgov.org (https://data.sfgov.org/Housing-and-Buildings/2012-Housing-Inventory/4xa2-t52k) which included data regarding eviction notices in San Franciso from 1997 to 2015. I have cleaned and reorganized the data using R (code shown at bottom, below data) for this particular example so that it includes columns for the year of the eviction notice (there is also data for month and day), the neighborhood (there is also data regarding zipcode, as well as, city block address), the justification for the eviction, and the number of instances of that particular justification in that year/neighborhood.
The larger dataset is very interesting, but I reduced it so that it might be possible to see trends in eviction justifications over time in different neighborhoods. It might also be useful to condense this data further by summing across justificaions to look at total eviction notices per year in each neighborhood.
###Note: These are eviction notices and may not represent actual evictions.