Created
April 1, 2022 22:31
-
-
Save TracyYXChen/ac03df37f2191121218c804f0a01d4e5 to your computer and use it in GitHub Desktop.
dvBar04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r} | |
# change the order | |
restaurant_df_long$scales <- factor(restaurant_df_long$scales, levels = c('Strongly agree', 'Agree', 'Strongly disagree','Disagree', 'Neutral')) | |
ggplot(data = restaurant_df_long, aes(x = restaurant, | |
y = signedCount, | |
fill = scales)) + | |
geom_col(width = 0.5) + | |
geom_text(aes(label = count), | |
position = position_stack(vjust = 0.5)) + | |
# flip x and y axis | |
coord_flip() + | |
scale_x_discrete() + | |
# use customized colors | |
scale_fill_manual(breaks = scales, | |
values = c( | |
"Strongly agree" = "hotpink1", | |
"Agree" = "lightpink1", | |
'Neutral' = 'gray', | |
'Strongly disagree' = "mediumpurple2", | |
'Disagree' = "mediumpurple4" | |
)) + | |
labs(title = "I had great dining experience") | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment