A slope graph showing how total points and shots per game changed from 2013/14 to 2014/15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) | |
| ) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 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") + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
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
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
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