如何在ggplot中的ylim上方和下方添加空间?

时间:2018-07-16 00:47:06

标签: r ggplot2

我想知道如何在r中使用ggplot在y min和y max上方和下方添加更多空间。下图显示了当前情况,但是我想在顶部数字上方和底部数字下方留出更多空间。

enter image description here

1 个答案:

答案 0 :(得分:0)

我直接从this post那里得到的:我认为这可以回答您的问题。

library(ggplot2)
x <- 1:4
y <- c(0, 0.0001, 0.0002, 0.0003)

dd <- data.frame(x, y)

scientific_10 <- function(x) {
  parse(text=gsub("e", " %*% 10^", scales::scientific_format()(x)))
}

ggplot(dd, aes(x, y)) + geom_point()+scale_y_continuous(label=scientific_10)
相关问题