Description Usage Arguments Author(s) See Also Examples
Bar plot themes
1 |
base_size |
Sent to |
orientation |
Is it a vertical or horizontal bar plot? |
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)
plot_data <- data.frame(
Language = c("French", "German", "Italian", "Spanish", "Swedish"),
Estimate = c(4.123, 5.12, 2.312, 3.83, 2.48)
)
p_default <- ggplot(plot_data, aes(x = Language, y = Estimate)) +
geom_bar(stat = "identity") +
scale_y_continuous(expand = c(0, 0))
p_default +
coord_flip() +
#tmt_label(aes(label = Estimate), nudge_y = .3) +
expand_limits(y = c(0, 6)) +
bar_theme(orientation = "hor")
grid.arrange(
p_default,
p_default + bar_theme(),
p_default + coord_flip(),
p_default + coord_flip() + bar_theme(orientation = "horizontal"),
nrow = 2, ncol = 2
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.