小编Dan*_*oop的帖子

在ggplot2中没有scale_y_continuous()的中断

我正在寻找一种方法,在不使用scale_y _...(breaks = c(x1,x2))函数的情况下在绘图中设置中断.问题如下:我想要一些箱形图.

    require(ggplot2)
    a <- rnorm(10, 0, 5)
    a <- as.data.frame(a); colnames(a) <- "test"

    ### original boxplot
    ggplot(data=a, mapping=aes(y=test, x=rep(1,10))) +
      geom_boxplot()

    ### scale_y_continous() cuts of my data points and changes the boxplot!
    ggplot(data=a, mapping=aes(y=test, x=rep(1,10))) +
      geom_boxplot() +
      scale_y_continuous(limits=c(-1,1), breaks=c(-1,0,1))

    ### I am therefore using coord_cartesian() but I am missing a breaks() function
    ggplot(data=a, mapping=aes(y=test, x=rep(1,10))) +
      geom_boxplot() +
      coord_cartesian(ylim = c(-1,1)) # +
    # breaks(c(-1,0,1))   # something like this
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!

r ggplot2

4
推荐指数
1
解决办法
9171
查看次数

标签 统计

ggplot2 ×1

r ×1