如何避免ggplot2中的折线

时间:2020-02-21 14:06:35

标签: r ggplot2

我尝试使用ggplot2软件包在R中绘制图形。假设我有以下数据:

df1<-data.frame(xpos=c(1,2,3,4),ypos=c(0.222,0.222,0.303,0.285))  

现在,我想绘制一个简单的折线图:

ggplot(data=df1, aes(x=xpos, y=ypos)) +
  geom_line()+
  geom_point()

enter image description here

现在,当我调整y轴时:

+scale_y_continuous("Y rates upd", breaks=seq(0,1,0.2),limits=c(0,1))

这些行“断”了 enter image description here

1 个答案:

答案 0 :(得分:1)

这取决于您的graphics device的图是从R发送到的。当我将其导出为PDF时,请参见下面的图。

enter image description here