如何在ggplot2中分隔x和y轴

时间:2015-07-28 13:49:42

标签: r ggplot2

这是我正在使用的数据:

 Habitat      x      y
Bukit Durang -0.318 -0.214
Bukit Durang  0.226 -0.450
Bukit Durang -0.074 -0.412
        HCV4  0.062 -0.140
        HCV4 -0.007  0.465
        HCV4 -0.096 -0.049
  Oil Palm 1 -0.281  0.058
  Oil Palm 1 -0.051  0.189
  Oil Palm 1 -0.058  0.188
  Oil Palm 2  0.415  0.024
  Oil Palm 2  0.137  0.136
  Oil Palm 2  0.564  0.205

我用它来生成带代码的图表:

  ggplot(MDS.Hym.Data, aes(x=x,y=y,shape = Habitat))+
  geom_point()+
  ylab("MDS Axis2")+
  xlab("MDS Axis1")+
  scale_y_continuous(limits = c(-0.5,0.5), breaks=c(-0.4,-0.2,0,0.2,0.4))+
  scale_x_continuous(limits = c(-0.6,0.6), breaks=c(-0.6,-0.3,0,0.3,0.6))+
  scale_shape_manual(values = c(15,17,4,1))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
        panel.background = element_blank(), axis.line = element_line(colour = "black"),
        axis.text.x = element_text(colour = "black"),
        axis.text.y = element_text(colour= "black"),
        legend.position = "none")

然而,这个图表连接了x和y轴。我想分开,因为两个轴都不是从0开始。

有人可以告诉我如何做到这一点吗?

由于

0 个答案:

没有答案