-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEEZ_by_year_month_streamgraph.R
More file actions
31 lines (24 loc) · 1.09 KB
/
EEZ_by_year_month_streamgraph.R
File metadata and controls
31 lines (24 loc) · 1.09 KB
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
# Library
library(streamgraph)
#real code
rm(list = ls())
setwd("C:/Data/Arctic/ArcticOptions/tables")
#read in data
myData = read.csv("C:/Data/Arctic/ArcticOptions/tables/streamgraphComponents.csv", header=T, sep=",")
myDate <- as.Date(myData$date, origin = "2009-09-01")
data=data.frame(myDate, myData$EEZ, myData$count)
#make streamgraph
##streamgraph(data, key="myData.EEZ", value="myData.count", date="myDate", offset="zero")
streamgraph(data, key="myData.EEZ", value="myData.count", date="myDate", offset = 1000000)
#or differently
streamgraph(data, "myData.EEZ", "myData.count", "myDate", offset = "zero", interactive = TRUE) %>%
sg_axis_x(1, "year", "%Y") %>%
sg_fill_brewer("PuOr")
#color palettes here: https://moderndata.plot.ly/create-colorful-graphs-in-r-with-rcolorbrewer-and-plotly/
#try to export as a png
library(webshot)
#install phantom
##webshot::install_phantomjs()
webshot("C:/Data/Arctic/ArcticOptions/tables/testpage.html" , "output.png", delay = 0.2 , cliprect = c(440, 0, 1000, 10))
##THIS DIDN'T WORK
#Instead I used SVG Crowbar Chrome add-on built by the NYTimes graphics folks