R 如何在气泡图中绘制ggplot 2中的背景几何线和几何线

R 如何在气泡图中绘制ggplot 2中的背景几何线和几何线,r,R,我想在气泡图上加一条垂直线和一条水平线,但不要把气泡画得太多。数据如下: a<-c("np", "prepp", "vp", "animal", "artifact", "communication", "ipv", "isv") b<-c(-0.51, 0.32, 0.85, -0.61, -0.36, 0.86, -0.02, 1.05) c<-c(0.10, 0.25, -0.20, 0.99, 1.09, -0.35, 0.00, -0.08) d<-c(68.2

我想在气泡图上加一条垂直线和一条水平线,但不要把气泡画得太多。数据如下:

a<-c("np", "prepp", "vp", "animal", "artifact", "communication", "ipv", "isv")
b<-c(-0.51, 0.32, 0.85, -0.61, -0.36, 0.86, -0.02, 1.05)
c<-c(0.10, 0.25, -0.20, 0.99, 1.09, -0.35, 0.00, -0.08)
d<-c(68.23, 4.87, 41.42, 2.44, 19.49, 2.44, 112.09, 2.44)
e<-c("synt", "synt", "synt", "sem", "sem", "sem", "cx", "cx")

data<-cbind(a, b, c, d, e)
colnames(data)<-c("Variables", "Dim.1", "Dim.2", "Freq_pmw", "SynSem_index")
data<-as.data.frame(data)
data[, 2]<-as.numeric(as.character(data[, 2]))
data[, 3]<-as.numeric(as.character(data[, 3]))
data[, 4]<-as.numeric(as.character(data[, 4]))

radius<-sqrt(data$Freq_pmw/pi)

plot<-ggplot(data, aes(x=data$Dim.1, y=data$Dim.2)) + 
  xlim(-1, 1.5) + ylim(-1, 3) + 
  theme_bw() + xlab("Dimension 1") + ylab("Dimension 2")
plot<-plot+geom_point(aes(size=radius, col="darkgrey", fill=data$SynSem_index), pch=21, show.legend=F)+
  scale_size_continuous(range=c(1, 20)) +
  geom_text_repel(label=data$Variables, size=3) +
  geom_vline(colour="red", xintercept=0) +
  geom_hline(colour="red", yintercept=0)
plot

a只需将
geom\u vline()
geom\u hline()
放在第一位(
ggplot2
按顺序绘制图层)

库(ggplot2);图书馆(ggrepel)

plot0如果您将几何线和几何线代码移到几何点上方,则该线将自动放置在您的点后面。谢谢您,Wyldsour和Ben Bolker!我忘了ggplot2是按顺序处理图层的。如果此答案解决了您的问题,建议您单击复选标记接受它。。
library(ggplot2); library(ggrepel)
plot0 <- ggplot(data, aes(x=Dim.1, y=Dim.2)) + 
   xlim(-1, 1.5) + ylim(-1, 3) + 
   theme_bw() + xlab("Dimension 1") + ylab("Dimension 2")


plot0 + geom_vline(colour="red", xintercept=0) +
        geom_hline(colour="red", yintercept=0) + 
        geom_point(aes(size=radius, fill=SynSem_index),
                   col="darkgrey", 
                   pch=21, show.legend=FALSE)+
   scale_size_continuous(range=c(1, 20)) +
   geom_text_repel(aes(label=Variables), size=3)