0
こんにちは、現在私、私は特定のカットオフggplots2:別のベクトルに基づいて点の色を変更します。
library(ggplot2)
library(ggrepel)
x = c(0.8846, 1.1554, 0.9317, 0.9703, 0.9053, 0.9454, 1.0146, 0.9012,
0.9055, 1.3307)
y = c(0.9828, 1.0329, 0.131, 1.3794, 0.9273, 0.3605, 1.0259, 0.9542,
0.9717, 0.9357)
z= c("a", "b", "c", "d", "e", "f",
"g", "h", "i", "j")
df = data.frame(x = x, y = y, z = z)
z <- as.vector(df$z)
ggplot(data = df, aes(x = x, y = y)) + theme_bw() +
geom_text_repel(data = subset(df, y > 1.3), aes(label = z),
box.padding = unit(0.45, "lines")) +
geom_point(aes(colour = cut(y, c(-Inf,0.2,0.5,Inf))), size = 3) +
# set color scales
scale_color_manual(
name = "p-values",
values = c("(-Inf,0.2]" = "blue",
"(0.2,0.5]" = "red",
"(0.5, Inf]" = "grey"))
に基づくポイントの色を変更することができプロットがグラフは次のようになり、
は、しかし、私はベースの色を変えることができる方法はあり別のベクトルのセットに置き換えます。例えば はX2で唯一のポイントは赤であり、X3は青とグレーの残りの部分になるように、私は、
x2<-c("a","b")
x3<-c("f")
が、私はそれを設定することができていると言いますか?前もって感謝します!
、 "blue"、 "gray"))))+ scale_color_identity()+ geom_point(size = 3) '? – lukeA