Description Usage Arguments Author(s) See Also Examples
Line plot themes
1 |
base_size |
Sent to |
box |
Whether to draw box or not. |
grid |
Which grid lines to draw (xy-string). |
Christofer Bäcklin
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 | library(ggplot2)
library(grid)
library(gridExtra)
set.seed(123)
plot_data <- data.frame(
Time = as.Date('2016-01-01') + 0:100,
Estimate = cumsum(rnorm(101)),
s = cumsum(rgamma(101, .1, 10))
)
p_default <- ggplot(plot_data, aes(x = Time, y = Estimate)) +
geom_line() +
geom_ribbon(aes(ymin = Estimate - s, ymax = Estimate + s), fill = "#00000022") +
scale_x_date(breaks = range(plot_data$Time)) +
scale_y_continuous(
breaks = c(0, range(plot_data$Estimate)),
labels = function(x) sprintf("%.2f USD", x)
)
grid.arrange(
p_default,
p_default + line_theme(),
p_default + line_theme(box = TRUE),
nrow = 2, ncol = 2
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.