Skip to content

Instantly share code, notes, and snippets.

View kpq's full-sized avatar

Kevin Quealy kpq

View GitHub Profile
@kpq
kpq / README.md
Last active December 23, 2015 15:19
Axis formatting and styling in D3

A demo of decent-looking axes and axis formatting in D3. SVG also styled to help understand margins.

@kpq
kpq / README.md
Created September 25, 2013 04:44
Line charts with dot annotation

Line charts with circles and labels. A demonstration of the technique for a student.

@kpq
kpq / README.md
Created September 25, 2013 06:39
Grouped bar charts

An example of d3 nesting with bar charts and rangebands. Original layout based on these bar charts of Oscar favorites for the New York Times.

@kpq
kpq / data.csv
Last active December 24, 2015 10:59
Multi-series line chart with date formatting
date val indicators
200309 4.5 Furniture_stores
200312 5.2 Furniture_stores
200403 9 Furniture_stores
200406 5.9 Furniture_stores
200409 6.7 Furniture_stores
200412 6 Furniture_stores
200503 5.2 Furniture_stores
200506 6 Furniture_stores
200509 5.2 Furniture_stores
@kpq
kpq / README.md
Last active December 24, 2015 16:39
Basic bar chart

A basic bar chart syntax, based off the example publised by the NYT in their series about ESPN.

@kpq
kpq / gist:7034291
Last active December 25, 2015 20:19
in class data cleaning
library(maptools)
get_second_element <- function(item) {
return (item[2])
}
get_first_element <- function(item) {
return (item[1])
}
@kpq
kpq / adoptions.R
Last active December 26, 2015 11:59
Scrape all U.S. adoptions by country of birth and year from the state department
get_country_data <- function(country_name) {
# this puts a plus instead of the space, which is how the URL behaves
country_name <- gsub(" ", "+", country_name)
#this fixes ivory coast
country_name <- gsub("`", "%60", country_name)
# first part of the url
first_part <- "http://adoption.state.gov/maps/statistics/map_files/statistics.php?special=NONE&year=ALL&country="
@kpq
kpq / README.md
Last active October 29, 2016 07:40
Dancing scatterplot

A short demo of scatterplots with animated transitions, based on this example from the New York Times.

@kpq
kpq / README.md
Created November 19, 2013 04:54
basic state choropleth starter

A basic starter for UCB students who want to make a choropleth map. Nearly identical to Mike Bostock's many examples with counties.

<style type="text/css">
svg {
border:1px solid #f0f;
font: 10px arial;
}
.product-name {
text-anchor: end;
font-size:13px;
font-weight:bold;