简体   繁体   中英

What function can I use to limit my y-axis in a geom_bar plot?

I am new to R and making a very simple histogram, however the range of my y-axis is too large and greatly limits visibility of the graph. I have tried using ylim however I get the error "Error in discrete_scale(c("x", "xmin", "xmax", "xend"), "position_d", : unused argument (ylim = c(0, 75))"

Here is the code used to make the histogram:

recipes %>%
mutate(ingredient = fct_infreq(ingredient)) %>%
ggplot(aes(x = ingredient)) +
geom_bar() +
scale_x_discrete(labels = NULL)

Any help and suggestions would be greatly appreciated.

you seem to have a wrong sintax in ylim. Try with:

recipes %>%
mutate(ingredient = fct_infreq(ingredient)) %>%
ggplot(aes(x = ingredient)) +
geom_bar() +
scale_x_discrete(labels = NULL) +
ylim(0, 75)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM