繁体   English   中英

我可以使用什么 function 来限制 geom_bar plot 中的 y 轴?

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

我是 R 的新手并制作了一个非常简单的直方图,但是我的 y 轴范围太大并且极大地限制了图表的可见性。 我曾尝试使用 ylim,但出现错误“discrete_scale 中的错误(c(“x”、“xmin”、“xmax”、“xend”)、“position_d”、:未使用的参数(ylim = c(0、75) )"

这是用于制作直方图的代码:

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

任何帮助和建议将不胜感激。

您似乎在 ylim 中有错误的语法。 尝试:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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