Description Usage Arguments Aesthetics Cosmetic Tips Examples
View source: R/stat_steamgraph.R
Plot multiple time series as a steamgraph
1 2 |
mapping |
mapping |
data |
data |
show.legend |
logical |
inherit.aes |
logical |
na.rm |
logical |
... |
other functions Plots geom_ribbon for each time series and stacks them one on top of the other. It's a more aesthetically appealing version of a stacked area chart. The groups with the most variance are placed on the outside, and the groups with the least variance are placed on the inside. |
geom_steamgraph needs x, y, group, fill.
The minimalist look can be achieved by appending the
following chunk of code to the example output object:
+
xlab(NULL) +
ylab(NULL) +
theme(
axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position = 'none',
strip.background = element_blank(),
# strip.text = element_blank(), # useful if only one year of data
plot.background = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
panel.grid = element_blank(),
panel.border = element_blank()
) +
coord_fixed( 0.2 * diff(range(df$Time)) / diff(range(df$Signal)))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | {
library(ggplot2)
set.seed(10)
df = data.frame(
Time=1:1000,
Signal=abs(c(cumsum(rnorm(1000, 0, 3)),
cumsum(rnorm(1000, 0, 4)), cumsum(rnorm(1000, 0, 1)),
cumsum(rnorm(1000, 0, 2)))),
Variable = c(rep('a', 1000), rep('b', 1000), rep('c',
1000), rep('d', 1000)),
VariableLabel = c(rep('Class A', 1000), rep('Class B',
1000), rep('Class C', 1000), rep('Class D', 1000))
)
ggplot(df, aes(x = Time, y = Signal, group = Variable, fill = VariableLabel)) +
stat_steamgraph()}
|
Loading required package: ggplot2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.