データを変更せずに積み重ねられたバープロットを作成したい。つまり、私はすでにプロットするパーセンテージを計算しています。 ggplot2のマニュアルによると、 "geom_colはstat_identityを使用しています。データはそのままです"。しかし、プロットのパーセンテージがサンプルデータのパーセンテージと異なるため、動作していないように見えます。データが変更されていない重ねられたオーバーレイバー
hereからサンプルデータをダウンロードします。
次のようにコードがある:(サンプルデータとの両方の画像からパーセントを比較)私はオプション「stat_identity」を使用した場合、データが変更されないまま、他の側では
ggplot(data=df, aes(x = Pathway, y = value, fill = variable)) +
scale_fill_manual(values=c("#005588", "#E69F00")) +
#stat_identity(geom="bar", width=0.5) +
geom_col(width=0.5) +
#geom_bar(stat="identity", width=0.5) +
facet_grid(. ~ Timepoint) +
coord_flip() +
theme_bw()
を、しかし、棒グラフはもう積み重ねられません。
「geom_col」オプションが機能していないか、私が何か間違ったことをやっていますか?別のプロット方法を使用すべきですか?どんな助けもありがとうございます。
dput:
structure(list(Pathway = c("Antigen Presentation Pathway", "Graft-versus- Host Disease Signaling",
"T Helper Cell Differentiation", "Cytotoxic T Lymphocyte-mediated Apoptosis of Target Cells",
"Communication between Innate and Adaptive Immune Cells", "Antigen Presentation Pathway",
"Graft-versus-Host Disease Signaling", "T Helper Cell Differentiation",
"Cytotoxic T Lymphocyte-mediated Apoptosis of Target Cells",
"Communication between Innate and Adaptive Immune Cells", "Antigen Presentation Pathway",
"Graft-versus-Host Disease Signaling", "T Helper Cell Differentiation",
"Cytotoxic T Lymphocyte-mediated Apoptosis of Target Cells",
"Communication between Innate and Adaptive Immune Cells", "Antigen Presentation Pathway",
"Graft-versus-Host Disease Signaling", "T Helper Cell Differentiation",
"Cytotoxic T Lymphocyte-mediated Apoptosis of Target Cells",
"Communication between Innate and Adaptive Immune Cells", "Antigen Presentation Pathway",
"Graft-versus-Host Disease Signaling", "T Helper Cell Differentiation",
"Cytotoxic T Lymphocyte-mediated Apoptosis of Target Cells",
"Communication between Innate and Adaptive Immune Cells", "Antigen Presentation Pathway",
"Graft-versus-Host Disease Signaling", "T Helper Cell Differentiation",
"Cytotoxic T Lymphocyte-mediated Apoptosis of Target Cells",
"Communication between Innate and Adaptive Immune Cells"), Timepoint = c("15DPI",
"15DPI", "15DPI", "15DPI", "15DPI", "30DPI", "30DPI", "30DPI",
"30DPI", "30DPI", "45DPI", "45DPI", "45DPI", "45DPI", "45DPI",
"15DPI", "15DPI", "15DPI", "15DPI", "15DPI", "30DPI", "30DPI",
"30DPI", "30DPI", "30DPI", "45DPI", "45DPI", "45DPI", "45DPI",
"45DPI"), variable = c("Targets", "Targets", "Targets", "Targets",
"Targets", "Targets", "Targets", "Targets", "Targets", "Targets",
"Targets", "Targets", "Targets", "Targets", "Targets", "DEGs",
"DEGs", "DEGs", "DEGs", "DEGs", "DEGs", "DEGs", "DEGs", "DEGs",
"DEGs", "DEGs", "DEGs", "DEGs", "DEGs", "DEGs"), value = c(2.63157894736842,
4.16666666666667, 1.36986301369863, 3.125, 1.12359550561798,
7.89473684210526, 18.75, 8.21917808219178, 18.75, 7.86516853932584,
15.7894736842105, 16.6666666666667, 10.958904109589, 9.375, 8.98876404494382,
44.7368421052632, 35.4166666666667, 43.8356164383562, 37.5, 31.4606741573034,
47.3684210526316, 43.75, 42.4657534246575, 37.5, 33.7078651685393,
52.6315789473684, 39.5833333333333, 39.7260273972603, 31.25, 31.4606741573034)), .Names = c("Pathway", "Timepoint", "variable",
"value"), class = "data.frame", row.names = c(NA, -30L))
あなたの予想される出力は何ですか?あなたが投稿したコードが私のために働いているようです –
バーを積み重ねることは、「そのままのままにする」とは異なります。あなたはデフォルトの 'position = 'stack''を使い、あなたが使用しているカスタム' position 'identity'を使いません。 – Gregor
@Mike H 2番目のプロットのように、サンプルデータの元のパーセント値が必要ですが、最初のプロットのように積み重ねられます。 – fred