The code below is from Creating a horizontal bar plots in the reverse direction.
I'd like to make a horizontal bar chart in the reverse direction but with a fixed scale. I'd like the scale of the plot to be fixed to 0 to 50 rather than the current 0 to 30.
I've tried changing scale_y_continuous()
to scale_y_discret()
and I've tried adding ylim()
but I can't seem to get it to work.
Thanks!
mtcars
mtcars$`car name` <- rownames(mtcars)
ggplot (mtcars, aes (x=`car name`, y=-mpg)) +
geom_bar (position = position_dodge(), stat = "identity",fill="red",colour="black") +
coord_flip () + theme_classic() +
scale_x_discrete(name = "", position = "top") +
scale_y_continuous(name = "mpg",
breaks = seq(0, -30, by = -10),
labels = seq(0, 30, by = 10)) + theme(axis.text.y = element_blank())