0

データ内の 2 つの異なる列によってファセット プロットを作成しようとしていTypeますUG。y 軸に別のラベルが必要だったので、ファセットのラベルの 1 つ (Typeのラベル) を外側に移動して、y 軸のラベルを置き換えました。UGここで、他のファセットのラベル (のラベル) をプロットの一番上に移動したいと思います。

ggplot(data = subset(Factors.longer, EQ == "CSI"), 
       aes(x = Girder, y = LLDF, fill = factor(S,levels = c("9","12","15")))) +
geom_boxplot(outlier.shape = NA, position = position_dodge(width = 0.75),
                 fatten = 1, lwd = 0.2) + theme_classic() +
    stat_summary(fun = mean, geom="point", shape=23, size=0.5, stroke = 0.2,
                 position = position_dodge(width = 0.75)) + 
    stat_boxplot(geom ='errorbar', linetype=1, width=0.5, lwd = 0.2, 
                 position = position_dodge(width = 0.75)) +
  geom_point(data = (subset(Factors.longer, Factor_EQ == "Factor 1 Proposed")), 
               aes(shape = Factor_EQ), stroke = 0.3, size = 1, position = position_dodge(width = 0.75)) +
  geom_point(data = (subset(Factors.longer, Factor_EQ == "Factor 2 Proposed")), 
               aes(shape = Factor_EQ), stroke = 0.3, size = 1, position = position_dodge(width = 0.75)) +
  geom_point(data = (subset(Factors.longer, Factor_EQ == "Factor 3 Proposed")), 
               aes(shape = Factor_EQ), stroke = 0.3, size = 1, position = position_dodge(width = 0.75)) +
  geom_vline(xintercept = 1.5, col='gray', lwd=0.2) +
  annotate("segment", x=-Inf, xend=Inf, y=-Inf, yend=-Inf, size = 0.35) +
  annotate("segment", x=-Inf, xend=Inf, y=Inf, yend=Inf, size = 0.35) +
  annotate("segment", x=-Inf, xend=-Inf, y=-Inf, yend=Inf, size = 0.35) +
  annotate("segment", x=Inf, xend=Inf, y=-Inf, yend=Inf, size = 0.35) +
  scale_shape_manual(values = c(0,2,4), labels=c("Factor 1", "Factor 2", "Factor 3")) +
      labs(x = element_blank(), shape = element_blank(), 
           fill = "Analytical Data with \n Girder Spacing (ft) of:") +
    theme(legend.title.align = 0.5, legend.position = "bottom", 
          axis.text.y = element_text(size=8, colour="black"),
          axis.text.x = element_text(size=8, colour="black", vjust=0.6),
          axis.title.y = element_text(size=8, colour="black", vjust=0.5, margin = margin(0,4,0,-6)),
          axis.line=element_blank(), strip.placement = "outside",
          axis.ticks = element_line(colour = "black", size = 0.2),
          legend.text = element_text(size=8, margin = margin(0,5,0,0)),
          legend.title = element_text(size=8, margin = margin(0,2,0,0)),
          strip.text.x = element_text(size = 8), axis.ticks.x=element_blank(),
          strip.background = element_blank(),
          legend.spacing.x = unit(0.1, 'cm'), legend.spacing.y = unit(0.1, 'cm'),
          legend.background = element_blank(), legend.box.background = element_rect(color = "black", size = 0.2)) +
  guides(fill = guide_legend(label.position = "bottom", label.hjust = 0.8, title.vjust = 0.8,
                             override.aes = list(shape = c(23))),
         shape = guide_legend(keywidth = unit(3, "mm"),keyheight = unit(7, "mm"))) +
 facet_wrap(UG~Type, scales='free_y', strip.position = "left", dir = "h",
                labeller = as_labeller(c(Moment = "Moment LLDF", Shear = "Shear LLDF",
                                         `84` = "UG-84", `92` = "UG-92", `100` = "UG-100",
                                         `108` = "UG-108", `116` = "UG-116", `124` = "UG-124")))  +
     ylab(NULL)

ここに画像の説明を入力

各行の列で隣り合う 2 つの結合プロットはすべて、同じUG-..ラベルを共有します。ラベルをファセット プロットの一番上に移動し、UG-..可能であれば共通のファセットをマージしたいと考えています。

望ましい出力は次のようになります。

ここに画像の説明を入力

データのいくつかの行:

> dput(Factors.longer[sample(seq(1,2808,1),50),])
structure(list(Factor = structure(c(2L, 1L, 3L, 2L, 3L, 2L, 1L, 
1L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 3L, 1L, 1L, 3L, 3L, 
1L, 1L, 3L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 3L, 1L, 1L, 3L, 
1L, 1L, 1L, 2L, 2L, 3L, 2L, 3L, 3L, 1L, 1L), .Label = c("Factor 1", 
"Factor 2", "Factor 3"), class = "factor"), UG = c(108, 116, 
100, 84, 116, 108, 116, 84, 116, 92, 84, 100, 100, 108, 116, 
92, 84, 84, 92, 100, 116, 124, 124, 108, 100, 108, 108, 116, 
84, 124, 100, 108, 108, 124, 124, 108, 92, 100, 124, 92, 84, 
84, 100, 84, 124, 100, 108, 124, 116, 116), S = c(9, 12, 9, 9, 
15, 12, 9, 12, 15, 9, 9, 12, 15, 9, 9, 12, 15, 9, 12, 12, 9, 
12, 15, 12, 9, 9, 15, 9, 9, 15, 9, 12, 12, 12, 15, 9, 9, 15, 
9, 12, 12, 9, 12, 9, 15, 12, 15, 12, 12, 9), X = c("Moment.Ext.Proposed", 
"Shear.Int.Proposed", "Moment.Ext.Proposed", "Shear.Ext.Proposed", 
"Moment.Int.Proposed", "Moment.Ext.Proposed", "Moment.Int.Proposed", 
"Shear.Ext.Proposed", "Moment.Int.Proposed", "Shear.Ext.Proposed", 
"Moment.Int.Proposed", "Moment.Ext.Proposed", "Shear.Ext.Proposed", 
"Shear.Int.Proposed", "Moment.Int.CSI", "Moment.Ext.Proposed", 
"Moment.Int.Proposed", "Shear.Ext.Proposed", "Moment.Ext.Proposed", 
"Shear.Int.Proposed", "Shear.Int.Proposed", "Shear.Ext.Proposed", 
"Shear.Int.Proposed", "Moment.Ext.Proposed", "Shear.Ext.Proposed", 
"Moment.Int.Proposed", "Shear.Ext.Proposed", "Moment.Int.CSI", 
"Shear.Int.Proposed", "Shear.Ext.Proposed", "Moment.Int.Proposed", 
"Shear.Ext.Proposed", "Shear.Int.Proposed", "Moment.Int.Proposed", 
"Moment.Ext.Proposed", "Moment.Ext.Proposed", "Moment.Ext.Proposed", 
"Shear.Int.Proposed", "Moment.Ext.Proposed", "Moment.Int.Proposed", 
"Shear.Int.Proposed", "Shear.Int.Proposed", "Shear.Int.Proposed", 
"Shear.Int.Proposed", "Shear.Ext.Proposed", "Shear.Int.Proposed", 
"Shear.Int.Proposed", "Moment.Ext.Proposed", "Moment.Int.Proposed", 
"Moment.Int.Proposed"), LLDF = c(0.533626409014319, 0.866405751413225, 
0.55765289242222, 0.711779585132152, 0.755186097872227, 0.800521967280557, 
0.491782992127421, 0.97614497639116, 0.794494246323854, 0.721101826662558, 
0.489418420320527, 0.80692500307713, 1.1401304762799, 0.532652061886602, 
0.581471397249951, 0.812616128459131, 0.821315397629657, 0.711779585132152, 
0.71012956439832, 0.851654824223441, 0.619610859476547, 0.916394738328302, 
0.915158721599485, 0.8143070793053, 0.716044123419053, 0.491031387041157, 
1.1309453929435, 0.581471397249951, 0.556659207027632, 1.15049317588068, 
0.490595996384418, 0.97952581080398, 0.745402203471413, 0.639770642593863, 
0.943170217245197, 0.559436941693265, 0.581174226731532, 0.958941443941545, 
0.562484996706972, 0.682125285585693, 0.828741547701049, 0.621407677361543, 
0.841349803198735, 0.556659207027632, 1.09531764896839, 0.841349803198735, 
0.93862143013564, 0.721642237814207, 0.698798472866865, 0.491782992127421
), Type = structure(c(1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L), .Label = c("Moment", "Shear"
), class = "factor"), Girder = c("Exterior Girder", "Interior Girder", 
"Exterior Girder", "Exterior Girder", "Interior Girder", "Exterior Girder", 
"Interior Girder", "Exterior Girder", "Interior Girder", "Exterior Girder", 
"Interior Girder", "Exterior Girder", "Exterior Girder", "Interior Girder", 
"Interior Girder", "Exterior Girder", "Interior Girder", "Exterior Girder", 
"Exterior Girder", "Interior Girder", "Interior Girder", "Exterior Girder", 
"Interior Girder", "Exterior Girder", "Exterior Girder", "Interior Girder", 
"Exterior Girder", "Interior Girder", "Interior Girder", "Exterior Girder", 
"Interior Girder", "Exterior Girder", "Interior Girder", "Interior Girder", 
"Exterior Girder", "Exterior Girder", "Exterior Girder", "Interior Girder", 
"Exterior Girder", "Interior Girder", "Interior Girder", "Interior Girder", 
"Interior Girder", "Interior Girder", "Exterior Girder", "Interior Girder", 
"Interior Girder", "Exterior Girder", "Interior Girder", "Interior Girder"
), EQ = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("CSI", "Proposed"), class = "factor"), 
Girder_S = c("Ext 9", "Int 12", "Ext 9", "Ext 9", "Int 15", 
"Ext 12", "Int 9", "Ext 12", "Int 15", "Ext 9", "Int 9", 
"Ext 12", "Ext 15", "Int 9", "Int 9", "Ext 12", "Int 15", 
"Ext 9", "Ext 12", "Int 12", "Int 9", "Ext 12", "Int 15", 
"Ext 12", "Ext 9", "Int 9", "Ext 15", "Int 9", "Int 9", "Ext 15", 
"Int 9", "Ext 12", "Int 12", "Int 12", "Ext 15", "Ext 9", 
"Ext 9", "Int 15", "Ext 9", "Int 12", "Int 12", "Int 9", 
"Int 12", "Int 9", "Ext 15", "Int 12", "Int 15", "Ext 12", 
"Int 12", "Int 9"), Factor_EQ = c("Factor 2 Proposed", "Factor 1 Proposed", 
"Factor 3 Proposed", "Factor 2 Proposed", "Factor 3 Proposed", 
"Factor 2 Proposed", "Factor 1 Proposed", "Factor 1 Proposed", 
"Factor 1 Proposed", "Factor 1 Proposed", "Factor 3 Proposed", 
"Factor 2 Proposed", "Factor 2 Proposed", "Factor 2 Proposed", 
"Factor 2 CSI", "Factor 1 Proposed", "Factor 2 Proposed", 
"Factor 2 Proposed", "Factor 3 Proposed", "Factor 1 Proposed", 
"Factor 1 Proposed", "Factor 3 Proposed", "Factor 3 Proposed", 
"Factor 1 Proposed", "Factor 1 Proposed", "Factor 3 Proposed", 
"Factor 3 Proposed", "Factor 3 CSI", "Factor 2 Proposed", 
"Factor 2 Proposed", "Factor 3 Proposed", "Factor 2 Proposed", 
"Factor 3 Proposed", "Factor 2 Proposed", "Factor 2 Proposed", 
"Factor 3 Proposed", "Factor 1 Proposed", "Factor 1 Proposed", 
"Factor 3 Proposed", "Factor 1 Proposed", "Factor 1 Proposed", 
"Factor 1 Proposed", "Factor 2 Proposed", "Factor 2 Proposed", 
"Factor 3 Proposed", "Factor 2 Proposed", "Factor 3 Proposed", 
"Factor 3 Proposed", "Factor 1 Proposed", "Factor 1 Proposed"
)), row.names = c(NA, -50L), groups = structure(list(UG = c(84, 
84, 84, 84, 84, 84, 84, 92, 92, 92, 92, 92, 100, 100, 100, 100, 
100, 100, 100, 100, 108, 108, 108, 108, 108, 108, 108, 108, 108, 
108, 116, 116, 116, 116, 116, 116, 116, 116, 124, 124, 124, 124, 
124, 124, 124, 124), S = c(9, 9, 9, 9, 12, 12, 15, 9, 9, 12, 
12, 12, 9, 9, 9, 12, 12, 12, 15, 15, 9, 9, 9, 9, 12, 12, 12, 
12, 15, 15, 9, 9, 9, 9, 12, 12, 15, 15, 9, 12, 12, 12, 15, 15, 
15, 15), Factor = structure(c(1L, 2L, 2L, 3L, 1L, 1L, 2L, 1L, 
1L, 1L, 1L, 3L, 1L, 3L, 3L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 3L, 3L, 
1L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, 2L, 3L, 1L, 1L, 1L, 3L, 3L, 2L, 
3L, 3L, 2L, 2L, 3L, 3L), .Label = c("Factor 1", "Factor 2", "Factor 3"
), class = "factor"), X = c("Shear.Int.Proposed", "Shear.Ext.Proposed", 
"Shear.Int.Proposed", "Moment.Int.Proposed", "Shear.Ext.Proposed", 
"Shear.Int.Proposed", "Moment.Int.Proposed", "Moment.Ext.Proposed", 
"Shear.Ext.Proposed", "Moment.Ext.Proposed", "Moment.Int.Proposed", 
"Moment.Ext.Proposed", "Shear.Ext.Proposed", "Moment.Ext.Proposed", 
"Moment.Int.Proposed", "Shear.Int.Proposed", "Moment.Ext.Proposed", 
"Shear.Int.Proposed", "Shear.Int.Proposed", "Shear.Ext.Proposed", 
"Moment.Ext.Proposed", "Shear.Int.Proposed", "Moment.Ext.Proposed", 
"Moment.Int.Proposed", "Moment.Ext.Proposed", "Moment.Ext.Proposed", 
"Shear.Ext.Proposed", "Shear.Int.Proposed", "Shear.Ext.Proposed", 
"Shear.Int.Proposed", "Moment.Int.Proposed", "Shear.Int.Proposed", 
"Moment.Int.CSI", "Moment.Int.CSI", "Moment.Int.Proposed", "Shear.Int.Proposed", 
"Moment.Int.Proposed", "Moment.Int.Proposed", "Moment.Ext.Proposed", 
"Moment.Int.Proposed", "Moment.Ext.Proposed", "Shear.Ext.Proposed", 
"Moment.Ext.Proposed", "Shear.Ext.Proposed", "Shear.Ext.Proposed", 
"Shear.Int.Proposed"), .rows = list(42L, c(4L, 18L), c(29L, 44L
), 11L, 8L, 41L, 17L, 37L, 10L, 16L, 40L, 19L, 25L, 3L, 31L,
20L, 12L, c(43L, 46L), 38L, 13L, 1L, 14L, 36L, 26L, 24L, 
6L, 32L, 33L, 27L, 47L, c(7L, 50L), 21L, 15L, 28L, 49L, 2L, 
9L, 5L, 39L, 34L, 48L, 22L, 35L, 30L, 45L, 23L)), row.names = c(NA, 
-46L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = 
c("grouped_df", "tbl_df", "tbl", "data.frame")) 
4

0 に答える 0