0

我想更改图表面板的顺序。目前我有 3 列我的不同类,我想要的是 1 列,其中 3 个类相互堆叠。它们都将具有相同的 X 轴(在本例中为主成分分析的值),然后对于我的 3 个类别中的每一个,冬季或夏季的季节仍将位于 Y 轴上。这就是我所拥有的:在此处输入图像描述 我用我的代码创建了这个:

bwplot(Comp1~ Season|Repro, data = moose,
   strip = strip.custom(var.name = c("f", "fc", "m"),strip.names=F, bg = 'white'),
   cex = .5, layout = c(3, 1),
   xlab = "Principal component 1", ylab = "Season",
   par.settings = list(
      box.rectangle = list(col = 1),
      box.umbrella  = list(col = 1),
      plot.symbol   = list(cex = .5, col = 1)),
       scales = list(x = list(relation = "same"),
                     y = list(relation = "same")))

另一种选择是将 2 个季节沿 X 轴放置在箱形图中,PCA 在 Y 轴上,但在这些季节中将 2 个季节分为 3 个组。与上面有 3 个面板的图表不同,我想要 2 个面板(夏季和冬季),然后在这 2 个面板中,将 f、fc、m 用于冬季分组并在下一个面板中(或在同一个图表中) ) f, fc, m 代表夏天。基本上像下一张图片,但把那张翻过来。我使用了这段代码,然后是上面的剩余代码来生成这个图表:bwplot(Season ~Comp1|Repro, data = moose,

在此处输入图像描述

这是用于尝试代码的示例数据。

structure(list(ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 
6L, 6L, 6L, 6L, 7L, 7L), .Label = c("F07002", "F07004", "F07005", 
"M07016", "M10007", "M10011", "M10015"), class = "factor"), Season = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L), .Label = c("SUM", 
"WIN"), class = "factor"), Time = structure(c(1L, 2L, 1L, 2L, 
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 
1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("day", "night"
), class = "factor"), Repro = structure(c(2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 
1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("f", "fc", "m"
), class = "factor"), Comp1 = c(-0.380080882, -0.610696209, -0.249409859, 
-0.409333188, -0.222490545, -0.204438065, -0.345230884, -0.142284942, 
0.750928418, 1.002325431, 0.450508246, 0.473959627, 1.059173278, 
0.911574612, 1.394915031, -0.448160403, -0.470799127, -0.760760938, 
-0.923465222, -1.522742066, -1.933918532, -0.83699801, -1.240214807, 
0.878163747, 0.756748992, 1.931795511, 1.802387012, 1.67483398, 
1.448883802, 0.974062472, 1.234001613, -0.439149936, -0.826745549, 
-0.42835036, -0.871512952, 0.17532518, 0.559407728, 0.976634392, 
-0.202405922, -0.633821539, -0.306163898, -0.302261589, 1.218779672, 
1.568575464, -0.310174732, -0.761785902), ln1wr = c(0.925765702, 
0.90999093, 1.109420337, 1.125676072, 1.081194815, 1.102770299, 
0.981029233, 1.019605156, 0.892407791, 0.894740178, 0.990098659, 
0.998570934, 1.280544881, 1.283292174, 0.152892746, 0.000499875, 
0.00039992, 0, 0, 1.820962221, 1.72698981, 1.829087366, 1.728020628, 
0.0009995, 0.000899595, 0, 0, 0.003693172, 0.003493889, 1.537705578, 
1.520475543, 1.410401436, 1.40550858, 1.258972223, 1.255302598, 
1.4981711, 1.505964504, 1.446048016, 1.132530507, 1.134944218, 
1.149653885, 1.148798304, 1.140553656, 1.14762465, 0.421797669, 
0.4069307)), .Names = c("ID", "Season", "Time", "Repro", "Comp1", 
"ln1wr"), class = "data.frame", row.names = c(NA, -46L))
4

1 回答 1

0

仍然不完全确定您想要什么,但在公式的 HTE LHS 上使用两个因子的交互函数可能会在转换为水平 TRUE 后得到您需要的东西。

bwplot(interaction(Season,Repro) ~ Comp1, data = moose,
   cex = .5, 
   xlab = "Principal component 1", ylab = "Season", horizontal=TRUE,
   par.settings = list(
      box.rectangle = list(col = 1),
      box.umbrella  = list(col = 1),
      plot.symbol   = list(cex = .5, col = 1)),
       scales = list(x = list(relation = "same"),
                     y = list(relation = "same")))

在此处输入图像描述

于 2012-11-23T15:19:51.280 回答