R ggplot2中每个面的不同轴限制

R ggplot2中每个面的不同轴限制,r,ggplot2,R,Ggplot2,我正试图在ggplot2中绘制一个刻面图,其中y轴显示标签,x轴应显示线图,每个标签的值采用两种不同的度量(不同的比例)。到目前为止,我有: Data <- structure(list(label = structure( c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L), .Label = c("A", "B", "C", "D", "E", "F"), class = "factor"), facet = struct

我正试图在
ggplot2
中绘制一个刻面图,其中y轴显示标签,x轴应显示线图,每个标签的值采用两种不同的度量(不同的比例)。到目前为止,我有:

Data <- structure(list(label = structure(
  c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 
  4L, 5L, 5L, 6L, 6L), .Label = c("A", "B", "C", "D", "E", "F"), class = "factor"), 
  facet = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
  1L, 2L), .Label = c("A", "B"), class = "factor"), value = c(0.0108889081049711, 
  0.37984336540103, 0.0232500876998529, 0.777756493305787, 
  0.0552913920022547, 0.920194681268185, 0.0370863009011373, 
  0.114463779143989, 0.00536034172400832, 0.469208759721369, 
  0.0412159096915275, 0.587875489378348), group = c(1, 1, 1, 
  1, 1, 1, 1, 1, 1, 1, 1, 1)), .Names = c("label", "facet", 
  "value", "group"), row.names = c(NA, -12L), class = "data.frame")

ggplot(Data, aes(x = label, y = value, group = group)) + geom_line() + 
     facet_grid(~ facet, scales = "free") + coord_flip()

Data手动更改轴方向,问题是:*ggplot2当前不支持带有非笛卡尔坐标或坐标翻转的自由缩放*

ggplot(Data, aes(y = label, x = value, group = group)) + geom_line() + 
 facet_grid(~ facet, scales = "free")

我想出了类似于df239的东西:

ggplot(Data, aes(y = label, x = value, group=group)) + geom_path() + 
  facet_wrap( ~ facet, scales = "free")
注意:您必须使用
geom_path
,并注意点的顺序,因为仅切换
x
y
coord_flip
(如另一个答案中所述,
facet_wrap
不支持)