如何在gggplot2-R圖中設(shè)置軸的限制?我的情節(jié)如下:library(ggplot2) carrots <- data.frame(length = rnorm(500000, 10000, 10000))cukes <- data.frame(length = rnorm(50000, 10000, 20000))
carrots$veg <- 'carrot'cukes$veg <- 'cuke'vegLengths <- rbind(carrots, cukes)ggplot(vegLengths, aes(length, fill = veg)) +
geom_density(alpha = 0.2)現(xiàn)在說(shuō)我只想在x=-5000到5000而不是整個(gè)范圍。我怎么能這么做?
3 回答

烙印99
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊
scale_x_continuous(limits = c(-5000, 5000))
coord_cartesian(xlim = c(-5000, 5000))
xlim
ylim
+ xlim(-5000, 5000)
coord_cartesian
.
ggplot2
- 3 回答
- 0 關(guān)注
- 1538 瀏覽
添加回答
舉報(bào)
0/150
提交
取消