ऐसा कुछ काम करना चाहिए। आपको और 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()

@Arun हाँ, निश्चित रूप से आप कर सकते थे और एक सही मायने में कम से कम उदाहरण के लिए पर्याप्त हो गया होता है कि के लिए। मैं डेटा फ्रेम का उपयोग करना चाहता था क्योंकि यह कई लेबलों (जैसे अंक जी 1 और जी 7) के लिए आसानी से विस्तार योग्य है। लेकिन 'एनोटेट' की याद दिलाना अच्छा है। – SlowLearner