library(ggplot2) library(gridExtra) p1 <- ggplot(primates,aes(x = Bodywt, y = Brainwt,label = rownames(primates))) + geom_point()+ geom_text(hjust = -0.1) + scale_y_continuous(breaks = seq(0, 1000, by = 200)) p2 <- ggplot(primates,aes(x = Bodywt, y = Brainwt,label = rownames(primates))) + geom_point()+ geom_text(hjust = -0.1) + xlab("Body weight (kg)") + ylab("Brain weight (g)") + xlim(0,250)+ scale_y_continuous(breaks = seq(0, 1400, by = 200)) grid.arrange(p1, p2, nrow=1) 将p1图中实心圆点改为空心
时间: 2023-07-15 15:11:04 浏览: 169
ggplot2实例
可以在 `p1` 中添加 `shape = 1` 参数即可将实心圆点变为空心圆点,修改后的代码如下:
```
library(ggplot2)
library(gridExtra)
p1 <- ggplot(primates,aes(x = Bodywt, y = Brainwt,label = rownames(primates))) +
geom_point(shape = 1) +
geom_text(hjust = -0.1) +
scale_y_continuous(breaks = seq(0, 1000, by = 200))
p2 <- ggplot(primates,aes(x = Bodywt, y = Brainwt,label = rownames(primates))) +
geom_point()+
geom_text(hjust = -0.1) +
xlab("Body weight (kg)") +
ylab("Brain weight (g)") +
xlim(0,250)+
scale_y_continuous(breaks = seq(0, 1400, by = 200))
grid.arrange(p1, p2, nrow=1)
```
运行后,`p1` 中的实心圆点就会变为空心圆点。
阅读全文