Display the names of specific elements in a plot
I have a volcano plot as shown in
http://i.stack.imgu开发者_运维知识库r.com/UreCs.jpg
I need to display the names of ONLY the elements which are shown in red color out of 19000 elements
How can I do that?
Also is there anyways I could represent those elements in the red color in different sizes based on their fold change and p-values?
You can label elements with the text
function. You could change the size of elements with the cex
argument to plot
, for instance
plot(1:10, cex=1:10*0.2)
text(c(1,2)+0.4, c(1,2), c("P1", "P2"))
Jana,
You can annotate your plots with text
. You can change many of the different elements of your plot by passing additional parameters in your call to plot
. Most of these parameters are discussed in detail on the ?par
page. Finally, you can specify logic in your calls to plot based on something of interest. Here's a quick example:
df <- data.frame(x = rnorm(100), y = rnorm(100))
with(df, plot(x,y
, cex = ifelse(abs(x) > 2, .75, 1.5) #Size
, col = ifelse(abs(x) > 2 | abs(y) > 2, "red", "blue") #Color
, pch = ifelse(abs(x) > 2 | abs(y) > 2, 4, 6) #Type of point
)
)
text(2, -3, "This is text on my plot")
精彩评论