是否有可能在切面图上切换Y轴断点和标签的边? [英] Is it possible to switch the side of y-axis breaks and labels on a faceted plot?

查看:130
本文介绍了是否有可能在切面图上切换Y轴断点和标签的边?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,在面ggplot(facet_grid)上,y轴facet标签位于右侧,y轴中断并且标签位于左侧。



是否可以切换它们?

解决方案

Koshke在ggplot2邮件列表中写下了这个笑话:http://groups.google.com/group/ggplot2/browse_thread/thread/5c4658aceea9daf1


$ b = pre> d < - data.frame(expand.grid(a = 1:2,b = 1:2,c = 1:2),x = rnorm 8),y = rnorm(8))
p <-ggplot(d,aes(x,y))+ facet_grid(a〜b)+ geom_point()+
coord_trans(x =reverse ,y =reverse)+
opts(strip.text.x = theme_text(angle = 180),
strip.text.y = theme_text(angle = 90),
axis .text.x = theme_text(angle = 180),
axis.text.y = theme_text(angle = 180),
axis.title.x = theme_text(angle = 180),
axis.title.y = theme_text(angle = 180))
print(p,vp = viewport(angle = 180))

显然你必须对其进行镜像或垂直翻转以获得所需的效果,但我不确定如何以及如何使用现在的图像软件。

还有 ... + coord_flip(),它将y轴置于底部, x轴在左边。


By default, on a faceted ggplot (facet_grid), the y-axis facet labels are on the right and the y-axis breaks and labels are on the left.

Is it possible to switch them?

解决方案

Koshke wrote this a while back, half as a joke on the ggplot2 mailing list: http://groups.google.com/group/ggplot2/browse_thread/thread/5c4658aceea9daf1

d <- data.frame(expand.grid(a=1:2,b=1:2,c=1:2),x=rnorm(8), y=rnorm(8)) 
p <- ggplot(d, aes(x, y)) + facet_grid(a~b) + geom_point() + 
coord_trans(x="reverse", y="reverse") + 
opts(strip.text.x=theme_text(angle=180), 
     strip.text.y=theme_text(angle=90), 
     axis.text.x=theme_text(angle=180), 
     axis.text.y=theme_text(angle=180), 
     axis.title.x=theme_text(angle=180), 
     axis.title.y=theme_text(angle=180)) 
print(p, vp=viewport(angle=180)) 

You would obviously have to mirror it or "flip vertically" for the desired effect, but I'm not sure how or if you can do that with modern image software.

There's also ... + coord_flip() which puts the y-axis at bottom and x-axis at left.

这篇关于是否有可能在切面图上切换Y轴断点和标签的边?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆