簡體   English   中英

限制ggplot2中Y軸顯示的值

[英]restricting Y axis displayed values in ggplot2

有人可以解釋為什么下面的代碼沒有切斷Y軸嗎? 我試圖切斷0到50000,並且僅顯示高於該值的值。 我根據這篇文章嘗試了這個

data(iris)
iris2<-iris[,1:4]*5000  

ggplot(data=iris2, aes(x=Sepal.Length, y=Sepal.Width, fill=Sepal.Length)) +
  coord_cartesian(ylim = c(5000, 150000)) +
  geom_bar(stat="identity")

將您的代碼更改為:

ggplot(data=iris2, aes(x=Sepal.Length, y=Sepal.Width, fill=Sepal.Length)) + ylim(c(5000, 150000)) +geom_bar(stat="identity")

您只需要ylim,就不需要coord_cartesian

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM