Guest User

Untitled

a guest
Dec 13th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. eg_data_x <- data.frame(
  2. period = c("1", "2", "1 + 2"),
  3. grp = c("1", "2", "1 + 2"),
  4. sum_period = c(20000, 30000, 50000))
  5. eg_data_x$period <- factor(eg_data_x$period, levels = c("1", "2", "1 + 2"))
  6. eg_data_x$grp <- factor(eg_data_x$grp, levels = c("1", "2", "1 + 2"))
  7.  
  8. total_chickens_by_period <- (
  9. (ggplot(data = eg_data_x, aes(x=period, y=sum_period, fill = grp)) +
  10. geom_bar(stat = "identity", color = "black")) +
  11. scale_fill_manual(values = c("red", "green", "gold")) +
  12. scale_y_continuous(labels = scales::comma) +
  13. geom_text(aes(label = sum_period), position = position_stack(vjust = 0.9), fontface = "bold") +
  14. ggtitle("Total Rubber Chickens by Period") + xlab("Period") + ylab("Chickens") +
  15. theme(plot.title = element_text(color = "black", size = 14, face = "bold", hjust = 0.5),
  16. axis.title.x = element_text(color = "black", size = 12, face = "bold"),
  17. axis.title.y = element_text(color = "black", size = 12, face = "bold")) +
  18. labs(fill = "Period") )
  19.  
  20. total_chickens_by_period
Add Comment
Please, Sign In to add comment