Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Late to this game, but I created a <a href="http://probabilitynotes.wordpress.com/2010/06/27/plot-multiple-time-series-using-the-flowinkblotriverribbonvolcanohourglassareawhatchamacallit-plots-blue-whale-catch-per-country-w-ggplot2/">stacked "blot" chart using ggplot2 and another set of data</a>. This uses geom_polygon after the data has been smoothed out.</p> <pre><code># data: Masaaki Ishida (luna@pos.to) # http://luna.pos.to/whale/sta.html head(blue, 2) ## Season Norway U.K. Japan Panama Denmark Germany U.S.A. Netherlands ## ## [1,] 1931 0 6050 0 0 0 0 0 0 ## ## [2,] 1932 10128 8496 0 0 0 0 0 0 ## ## U.S.S.R. South.Africa TOTAL ## ## [1,] 0 0 6050 ## ## [2,] 0 0 18624 hourglass.plot &lt;- function(df) { stack.df &lt;- df[,-1] stack.df &lt;- stack.df[,sort(colnames(stack.df))] stack.df &lt;- apply(stack.df, 1, cumsum) stack.df &lt;- apply(stack.df, 1, function(x) sapply(x, cumsum)) stack.df &lt;- t(apply(stack.df, 1, function(x) x - mean(x))) # use this for actual data ## coords.df &lt;- data.frame(x = rep(c(df[,1], rev(df[,1])), times = dim(stack.df)[2]), y = c(apply(stack.df, 1, min), as.numeric(apply(stack.df, 2, function(x) c(rev(x),x)))[1:(length(df[,1])*length(colnames(stack.df))*2-length(df[,1]))]), id = rep(colnames(stack.df), each = 2*length(df[,1]))) ## qplot(x = x, y = y, data = coords.df, geom = "polygon", color = I("white"), fill = id) # use this for smoothed data density.df &lt;- apply(stack.df, 2, function(x) spline(x = df[,1], y = x)) id.df &lt;- sort(rep(colnames(stack.df), each = as.numeric(lapply(density.df, function(x) length(x$x))))) density.df &lt;- do.call("rbind", lapply(density.df, as.data.frame)) density.df &lt;- data.frame(density.df, id = id.df) smooth.df &lt;- data.frame(x = unlist(tapply(density.df$x, density.df$id, function(x) c(x, rev(x)))), y = c(apply(unstack(density.df[,2:3]), 1, min), unlist(tapply(density.df$y, density.df$id, function(x) c(rev(x), x)))[1:(table(density.df$id)[1]+2*max(cumsum(table(density.df$id))[-dim(stack.df)[2]]))]), id = rep(names(table(density.df$id)), each = 2*table(density.df$id))) qplot(x = x, y = y, data = smooth.df, geom = "polygon", color = I("white"), fill = id) } hourglass.plot(blue[,-12]) + opts(title = c("Blue Whale Catch")) </code></pre> <p><a href="http://probabilitynotes.files.wordpress.com/2010/06/bluewhalecatch.png">alt text http://probabilitynotes.files.wordpress.com/2010/06/bluewhalecatch.png</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload