【发布时间】:2022-01-20 01:42:23
【问题描述】:
我已经在 r 并排视图上制作了一个散点图,并且很难在相同的比例上得到它,有没有办法简单地做到这一点?都在 15-30 的 y 轴刻度上
这是我目前的代码
p1 <- ggplot(covid, aes(x=covid1$oct2019_rent, y=covid1$Depression.2019))+ geom_point()+ ggtitle("Depression Rates Vs Rise in Rent")+ xlab("October 2019 Rent")+ ylab("Depression 2019")
p2 <- ggplot(covid, aes(x=covid1$oct2020_rent, y=covid1$Depression.2020)) + geom_point()+
xlab("October 2020 Rent")+
ylab("Depression 2020")
p1 + p2
这是我的数据的样子
【问题讨论】:
-
在两个图中添加
+ scale_y_continuous(limits = c(15, 30)) -
而且,仅供参考,不要将
data$column放在aes()中——这就是data参数的用途。简化为ggplot(covid, aes(x = oct2020_rent, y = Depression.2020)) -
不知道用
facet_wrap或facet_grid会不会更方便
标签: r ggplot2 scale scatter-plot