我怎样才能使这两个地块的绘图面积相同呢?
library(ggplot2)
ggplot(data=iris, mapping = aes(Sepal.Length, Sepal.Width)) + geom_point()
ggplot(data=iris, mapping = aes(Sepal.Length, Sepal.Width, col=Species)) + geom_point()
目标是在动画中叠加情节,我希望所有的间距都一样。
发布于 2020-11-10 22:37:03
保留空间的一种方法是允许在第二个情节中创建图例,但将所有的图例元素设置为在背景下不可见。
library(ggplot2)
ggplot(data=iris, mapping = aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
scale_color_manual(values = rep("black", 3)) +
theme(legend.key = element_rect(fill = "white"), legend.text = element_text(color = "white"), legend.title = element_text(color = "white")) +
guides(color = guide_legend(override.aes = list(color = NA)))
ggplot(data=iris, mapping = aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point()
https://stackoverflow.com/questions/64777426
复制相似问题