回答編集履歴
1
test
CHANGED
@@ -3,21 +3,19 @@
|
|
3
3
|
> ・グラフ内の描画デザインが変わらない
|
4
4
|
|
5
5
|
「エラーバーの位置が大きくずれる」問題ですが、これはデータ(`Treatment`)の順序が並び替えられているためです。なので、順序を元のままに保つために `geom_bar_pattern()` に `group = interaction(BbCc, Treatment)` を追加します。
|
6
|
-
※ 「グラフの枠線が表示されない」と「グラフ内の描画デザインが変わらない」についてはよく分かりませんので、以下のコードでは `scale_fill_manual()` と `scale_color_manual()` はコメントアウトしています
|
7
6
|
```r
|
8
7
|
g_Test <- ggplot(Test_Data, aes(x = size, y = ave, fill = Treatment))+
|
9
|
-
geom_bar_pattern(stat = "identity", position = "dodge",
|
8
|
+
geom_bar_pattern(stat = "identity", position = "dodge", color="black", linewidth=.2,
|
10
9
|
aes(group = interaction(BbCc, Treatment), pattern = BbCc, pattern_fill = Aa, pattern_colour = Aa))+
|
11
10
|
scale_pattern_fill_manual(values = c( A = "skyblue", a = "red"))+
|
12
11
|
scale_pattern_color_manual(values = c(A = "skyblue", a = "red"))+
|
13
|
-
|
12
|
+
scale_fill_manual(values = c("ABC" = "skyblue", "ABc" = "NA", "AbC" = "NA", "Abc" = "NA",
|
14
|
-
|
13
|
+
"aBC" = "red", "aBc" = "NA", "abC" = "NA", "abc" = "NA"))+
|
15
|
-
|
14
|
+
scale_color_manual(values = c("ABC" = "skyblue", "ABc" = "skyblue", "AbC" = "skyblue", "Abc" = "skyblue",
|
16
|
-
|
15
|
+
"aBC" = "red", "aBc" = "red", "abC" = "red", "abc" = "red"))+
|
17
16
|
geom_errorbar(aes(ymax = ave + se, ymin = ave - se), position = "dodge")+
|
18
17
|
labs(x = "size", y = "ave")+
|
19
18
|
theme_classic()+
|
20
19
|
theme(text = element_text(size=16))
|
21
20
|
```
|
22
|
-
|
23
|
-
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2025-01-08/
|
21
|
+
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2025-01-08/0823c8e7-3d1c-4992-9cbd-31591b8f6eb2.png)
|