ggplot 0.9.3问题与facet_wrap,自由磅秤和coord_flip - 第二次尝试 [英] ggplot 0.9.3 issue with facet_wrap, free scales and coord_flip - 2nd try

查看:152
本文介绍了ggplot 0.9.3问题与facet_wrap,自由磅秤和coord_flip - 第二次尝试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前用于完美工作的旧代码不再适用于0.9.3。这个问题与使用方面,自由磅秤和坐标翻转有关。



以下是一种重现方法:



数据集:d.csv:

 优先级,所有者,项目
中等,owner7,Team4
中等,owner1,Team1
低,,Team3
高 ,Team3
Medium,,Team4
Medium,owner3,Team1
Medium,owner2,Team1
Medium,owner5,Team2
Low,owner4,Team2
Critical,,Team2
Medium, owner2,Team1
高,,Team4

代码:

 数据<  -  read.csv(file =d.csv,head = TRUE)
附加(数据)

p3 < - ggplot(aes(y = .. count ..))+
facet_wrap(〜Project,nrow = 2,scales =free)+
opts(legend.position =none)

这会创建一个多面图,但我需要翻转轴。以前,添加一个coord_flip()来做到这一点,但现在新的ggplot不允许一起使用自由缩放和coord_flip。有没有其他的方式来转动方面的轴?自由秤对我很重要。感谢您提供任何指针。

解决方案

2016年末每月更新: coord_flip 中已经修复了c>, facet_grid scales =free GGPLOT2 。您可以使用

  install.packages(devtools)
devtools :: install_github(hadley / ggplot2 )

注意,试试 free_x free_y 取决于您的需求,因为并不总是清楚 x y 表示当你翻转坐标时。


An old code that used to work perfectly no longer works with 0.9.3. The issue is related to the use of facets, free scales and coord flip.

Here is a way to reproduce:

data set: 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"

Code:

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") 

This creates a faceted plot but I need the axes flipped. Previously, adding a coord_flip() did the trick but now the new ggplot does not permit using free scales and coord_flip together. Is there any other way to turn the facet axes around? The free scales are important to me. Thanks for any pointers.

解决方案

Update per late 2016: This bug with coord_flip, facet_grid and scales="free" has been fixed in the development version of ggplot2. You can install it with

install.packages("devtools")
devtools::install_github("hadley/ggplot2")

Note, try both free_x and free_y depending on your needs, because it is not always clear what x and y mean when you have flipped the coordinates.

这篇关于ggplot 0.9.3问题与facet_wrap,自由磅秤和coord_flip - 第二次尝试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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