如果我使用ggplot,那么x轴(y == 0)的水平线与y的任何其他值相同.我想强调一下这样一个事实:图的底部不是x轴,并且图中的x轴更高.我怎样才能做到这一点?
data.df <- data.frame(Plant = c("Plant1", "Plant1", "Plant1", "Plant2", "Plant2", "Plant2"), Type = c(1, 2, 3, 1, 2, 3), Axis1 = c(0.2, -0.4, 0.8, -0.2, -0.7, 0.1), Axis2 = c(0.5, 0.3, -0.1, -0.3, -0.1, -0.8))
ggplot(data.df, aes(x = Axis1, y = Axis2, shape = Plant, color = Type)) + geom_point(size = 5)
Run Code Online (Sandbox Code Playgroud)
您可以用黑线突出显示轴
ggplot(data.df, aes(x = Axis1, y = Axis2, shape = Plant, color = Type)) +
geom_point(size = 5) +
geom_hline(aes(yintercept = 0)) +
geom_vline(aes(xintercept = 0))
Run Code Online (Sandbox Code Playgroud)
您还可以通过添加直接更改轴的颜色和宽度,例如:
+ theme(axis.line = element_line(colour = 'red', size = 2))
Run Code Online (Sandbox Code Playgroud)