I am trying to adjust the y-axis of this graph so that it starts at 1 instead of 0. What's the best way to do this?
The solution offered here cuts off the bottom of the graph. I would like for the bars to look pretty much identical to the graph below, but with the lower y-limit at 1 and each bar moved down 1 unit to match. I would like to preserve the small amount of gray space below each bar.
Code:
groups %>% ungroup() %>% mutate(message = fct_relevel(message, "Personal", "General"), enviroattitudeshalf = fct_relevel(enviroattitudeshalf, "Low Environmental Attitudes", "High Environmental Attitudes")) %>% ggplot(aes(x = message, y = mean)) + geom_col(width = 0.5, fill = "003900") + geom_text(aes(label = round(mean, digits = 1), vjust = -2)) + geom_errorbar(aes(ymin = mean - se, ymax = mean + se), width = .2, position = position_dodge(.9)) + labs(title = "Environment: Evaluations of Personal and General Convincingness", y = "Rating", x = "Personal evaluation or general evaluation") + ylim(0, 8) + facet_wrap(~enviroattitudeshalf)
Data:
structure(list(enviroattitudeshalf = c("Low Environmental Attitudes", "Low Environmental Attitudes", "High Environmental Attitudes", "High Environmental Attitudes"), message = c("General", "Personal", "General", "Personal"), mean = c(3.89473684210526, 3.37894736842105, 4.43636363636364, 5.10909090909091), se = c(0.145460372156746, 0.19522803582675, 0.160549137262631, 0.171509247396541)), row.names = c(NA, -4L), groups = structure(list(enviroattitudeshalf = c("High Environmental Attitudes", "Low Environmental Attitudes"), .rows = structure(list(3:4, 1:2), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", "list"))), row.names = 1:2, class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = c("grouped_df", "tbl_df", "tbl", "data.frame"))
https://stackoverflow.com/questions/66084411/changing-lower-limit-of-graph-y-axis-when-x-is-a-discrete-variable-without-cutti February 07, 2021 at 11:56AM
没有评论:
发表评论