r绘图0不在原点的问题

使用plot画图的时候,只是设定xy轴范围仍然在0之前会有一小段多出来的范围 例如:plot(runif(10,0,10),type="l",xlim=c(0,10),ylim=c(0,10)) 使用:xaxs/yaxs="i" 代码即可解决 例如:plot(r...

使用plot画图的时候,只是设定xy轴范围仍然在0之前会有一小段多出来的范围

例如:plot(runif(10,0,10),type="l",xlim=c(0,10),ylim=c(0,10))

attachments-2022-10-MDimydIM635260e78b52d.png使用:xaxs/yaxs="i" 代码即可解决

例如:plot(runif(10,0,10),type="l",xlim=c(0,10),ylim=c(0,10),yaxs="i",xaxs="i")

attachments-2022-10-Fap7j6Z5635264a994ea6.png

同样,ggplot也会有这个问题,处理方式为在图形p后加一段参数

    scale_y_continuous(expand = c(0, 0))+

    scale_x_continuous(expand = c(0, 0))



例如ggplot()+

    geom_density(aes(x=runif(10,0,10)))+

    scale_y_continuous(expand = c(0, 0))+

    scale_x_continuous(expand = c(0, 0))


attachments-2022-10-bM9WYj2j63526661d31fb.png

  • 发表于 2022-10-21 17:29
  • 阅读 ( 1343 )
  • 分类:R

0 条评论

请先 登录 后评论
xun
xun

电路元件工程师

66 篇文章

作家榜 »

  1. omicsgene 654 文章
  2. 安生水 325 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. 红橙子 78 文章
  6. CORNERSTONE 72 文章
  7. rzx 67 文章
  8. xun 66 文章