7

示例演示中的这个简单代码在 0.9.3 中不再有效。

require(ggplot2)
p <- qplot(displ, hwy, data = mpg)
p + facet_wrap(~ cyl, scales = "free_y") + coord_flip()

上面的代码现在产生错误:

Error in facet_render.wrap(plot$facet, panel, plot$coordinates, plot_theme(plot),  : 
  ggplot2 does not currently support free scales with a non-cartesian coord or coord_flip.

有什么解决方法可以得到类似的东西。谢谢!

==================================================== ==== 第二次尝试

最后来创建一个小例子。这是一种重现的方法:

数据集:d.csv:

"Priority","Owner","Project"
"Medium","owner7","Team4"
"Medium","owner1","Team1"
"Low","","Team3"
"High","owner6","Team3"
"Medium","","Team4"
"Medium","owner3","Team1"
"Medium","owner2","Team1"
"Medium","owner5","Team2"
"Low","owner4","Team2"
"Critical","","Team2"
"Medium","owner2","Team1"
"High","","Team4"

代码:

data <- read.csv(file="d.csv",head=TRUE)
attach(data)

p3 <- ggplot(data,aes(x=Owner,fill=Priority))+
geom_bar(aes(y=..count..)) + 
facet_wrap(~ Project, nrow=2, scales="free") +
opts(legend.position="none") 

这会创建一个多面图,但我需要翻转轴。以前,添加 coord_flip() 可以解决问题,但现在新的 ggplot 不允许同时使用自由比例和 coord_flip。有没有其他方法可以转动刻面轴?自由秤对我很重要。感谢您的任何指示。

4

0 回答 0