Skip to content

Instantly share code, notes, and snippets.

View jalapic's full-sized avatar

James Curley jalapic

View GitHub Profile
#Geom Tiling
df <- data.frame(Var1=rep(LETTERS[1:20],20),
Var2=rep(LETTERS[1:20],each=20),
Value=sample(1:100, replace=T, 400)
)
@jalapic
jalapic / viridisschiz
Created October 3, 2015 01:27
Australian Schizophrenia Births
### Example Viridis Plot
library(ggplot2)
library(viridis)
library(season)
library(gridExtra)
pa<-ggplot(schz, aes(year, month, fill = SczBroad)) +
geom_tile(colour="gray20", size=1.5, stat="identity") +
scale_fill_viridis(option="A") +
@jalapic
jalapic / gist:47b0be9cff2732267949
Created September 30, 2015 16:53
NHL Small Multiple
# Making an NHL Small Multiple
# this is only minimally annotated - sorry
# Libraries we'll use
library(dplyr)
library(magrittr)
library(XML)
library(ggthemes)
library(ggplot2)
@jalapic
jalapic / README.md
Last active September 24, 2015 03:07
NHL Slope Graph

NHL slope graph

A slope graph showing how total points and shots per game changed from 2013/14 to 2014/15

@jalapic
jalapic / README.md
Last active September 24, 2015 01:32
slope, 2 transitions

Transitioning Slope Chart

This slope chart transitions between two y-axes

  • has options for hovering to pick out line/circle combinations
@jalapic
jalapic / README.md
Created September 24, 2015 00:41
slope, one transition

Slope Chart

  • this slope chart will transition from one set of data to another on click of the update button.

To do:

  • enable going back to original data on re-click
  • color gradient based on difference between y1,y2
@jalapic
jalapic / README.md
Last active September 23, 2015 04:49
Slope Chart

Slope Chart

  • a very simple slope chart
@jalapic
jalapic / README.md
Last active September 22, 2015 04:17
bars, sidebyside, sort

Laying out pages

Example tweaked from original example by Scott Murray.

  • use div, class & id to layout page with HTML

  • use d3.select, .node().clientWidth to ensure svg width is consistent with css

  • use d3.select to append svg to correct chartContainer (id), ids have to be unique

@jalapic
jalapic / README.md
Last active September 22, 2015 00:56
bars: links,sorting

Linked bar charts with sorting functions

Copied and tweaked from Scott Murray's examples. This gives introduction to:

  • linking together two graphs built from same dataset
  • adding 3 different sorting buttons based on ascending/descending of different variables
@jalapic
jalapic / README.md
Created September 21, 2015 01:41
Bars, sort buttons

Bars, sort buttons

A sort button example taken from Scott Murray's excellent tutorials and tweaked a little.

  • divs for buttons
  • sort data dynamically by changing order of 's based on data values