何かこれはうまくいくはずです。あなたはx
とy
の引数をgeom_text()
に混乱させる必要があります。
library(ggplot2)
highlight.gene <- "G1"
set.seed(23456)
a <- data.frame(GeneName = paste("G", 1:10, sep = ""),
Index1 = runif(10, 100, 200),
Index2 = runif(10, 100, 150))
a$highlight <- ifelse(a$GeneName == highlight.gene, "highlight", "normal")
textdf <- a[a$GeneName == highlight.gene, ]
mycolours <- c("highlight" = "red", "normal" = "grey50")
a
textdf
ggplot(data = a, aes(x = Index1, y = Index2)) +
geom_point(size = 3, aes(colour = highlight)) +
scale_color_manual("Status", values = mycolours) +
geom_text(data = textdf, aes(x = Index1 * 1.05, y = Index2, label = "my label")) +
theme(legend.position = "none") +
theme()
![screenshot](https://i.stack.imgur.com/TaIZf.png)
@Arunはい、確かにあなたは可能性があり、十分なされているだろう、本当に最小限例えば。データフレームは、複数のラベル(たとえば、ポイントG1とG7)に簡単に展開できるので、私はデータフレームを使いたいと思っていました。しかし、注釈を思い出すことは良いことです。 – SlowLearner