我需要此功能来绘制散点图。我得到的是一个具有正值和负值的图,但我希望y轴和x轴在原点交叉。你知道怎么做吗?
BasicScatterPlotClassWrapper_PL<- function(
#pivot.aggregation,
sample,
#pivot.aggregationCol,
pivot.var,
pivot.title,
lab.size,
pivot.dot.size,
pivot.ylab,
pivot.xlab,
font.size.x,
font.size.y,
pivot.lab,
variable_y,
variable_x,
threshold,
dot.size) {
gg <- ggplot(sample_w, aes(x.calc,y.calc)) +
ggtitle(pivot.title) +
geom_point(aes(colour= Colours$blue),size=dot.size) +
scale_color_manual(values= Colours$blue) +
ggrepel::geom_text_repel(aes(x.calc,y.calc, label = label), size = pivot.lab ,fontface = "bold") +
geom_abline(intercept = 0, slope = 1) +
xlab(pivot.xlab) +
ylab(pivot.ylab) +
scale_y_continuous(limits= c(-4,4)) +
scale_x_continuous(limits= c(-6,6)) +
coord_fixed(ratio = 1, xlim = NULL, ylim = NULL, expand = TRUE, clip = "off") +
theme(axis.title.y = element_text(face = "bold", size = 9, color="black"),
axis.title.x = element_text(face = "bold", size = 9, color="black"),
axis.text.x=element_text(size = font.size.x, face = "bold",hjust= 0.5),
axis.text.y=element_text(size = font.size.y, face = "bold",hjust= 0.5),
legend.position="none",
panel.background = element_rect(fill = "transparent", colour = NA),
axis.line = element_line(size = 0.2, colour = "black")) +
return(gg)
}
非常感谢