用于构面的 xlabel 和 ylabel
我正在这样做:
ggplot(IDPlotLn, aes(x=CO3, y=CRf)) +
xlab(xlabel) +
ylab(ylabel) +
opts(
axis.text.x = theme_text(size=10, face="plain", colour="black",vjust=1),
axis.text.y = theme_text(size=10, face="plain", colour="black", hjust=1)) +
scale_y_continuous(limits = c(-1.3 , 1.3), expand = c(0,0)) +
opts(panel.margin=unit(1, "cm")) +
geom_point() +
geom_smooth(method="lm",se=F) +
facet_wrap(~ ID, nrow=7, ncol=3, scales = "free") +
opts(strip.text.x = theme_text(size = 8))
我想为我的每个方面绘制 Xlabel 和 ylabel,相同的 xlabel 和 ylabel。像这样,我的所有方面只有一个 xlabel 和 ylabel。
是否可以?
谢谢你的回答,我不知道gridExtra。
但在这个例子中,我进行了分面,我只是想让它更漂亮,我想为每个面板添加相同的 xlabel 和 ylabel。 因为之后我想从所有面板中选择几个面板,所以如果我已经有了 x 和 y 标签,那就太好了。
I'm doing like this:
ggplot(IDPlotLn, aes(x=CO3, y=CRf)) +
xlab(xlabel) +
ylab(ylabel) +
opts(
axis.text.x = theme_text(size=10, face="plain", colour="black",vjust=1),
axis.text.y = theme_text(size=10, face="plain", colour="black", hjust=1)) +
scale_y_continuous(limits = c(-1.3 , 1.3), expand = c(0,0)) +
opts(panel.margin=unit(1, "cm")) +
geom_point() +
geom_smooth(method="lm",se=F) +
facet_wrap(~ ID, nrow=7, ncol=3, scales = "free") +
opts(strip.text.x = theme_text(size = 8))
I want to plot Xlabel and ylabel for each one of my facet, the same xlabel and ylabel. Like this I have only one xlabel and ylabel for all of the facet.
Is it possible?
Thank you for yours answer, I didn't know gridExtra.
But in this example, I'm faceting and I just want to make it more beautiful, it is the same xlabel and ylabel that I want to add for each panel.
Because after for I want to choose several panels from all my panels, so it can be nice if I have already x and y label.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在分面时尝试对 x 轴和 y 轴使用不同的标签,那么正确的答案是您可能不应该使用分面。分面的全部意义在于每个面板共享相同的 x 和 y 轴。因此,如果您以不同的方式标记它们,则很可能您滥用了分面。
您可能想要的是简单地单独绘制每个面板,然后将它们排列在网格中。借助
gridExtra
包,这可以在ggplot2
中轻松完成:请参阅
?grid.arrange
了解更多示例。If you are trying to use different labels for the x and y axes when faceting then the correct answer is that you probably shouldn't be using facets. The entire point of faceting is that each panel shares the same x and y axis. So if you're labeling them differently, chances are you're misusing faceting.
What you probably want instead is to simply plot each panel separately and then arrange them in a grid. This can be easily done in
ggplot2
with the help of thegridExtra
package:See
?grid.arrange
for more examples.