In ggplot2 , how to align label x in vertical ? The wished result as attached image .
library(tidyverse)
category <- c("A B C","DF GC","S AA")
amount <- c(3,2,1)
plot_data <- data.frame(category,amount)
plot_data %>% ggplot(aes(x=category,y=amount)) geom_col()
CodePudding user response:
Try this:
library(tidyverse)
category <- c("A B C", "DF GC", "S AA")
amount <- c(3, 2, 1)
plot_data <- data.frame(category, amount)
plot_data %>%
mutate(category = str_wrap(category, 1)) %>%
ggplot(aes(category, amount))
geom_col()
Created on 2022-05-07 by the reprex package (v2.0.1)