Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add text in my boxplot? [duplicate]

Tags:

r

I have plotted box plot for my data using given command and trying to write text (p-value ) in it.

Using :

boxplot(data,ylab = prop_index[i])
text(1:2 - 0.4, data[,1]/2, paste("p-value=",p_val)) 

I applied "text" command but noting has appeared on image. Please tell me appropriate method to apply this command

Box plots are given

like image 848
user96368 Avatar asked Dec 24 '22 10:12

user96368


1 Answers

x1 <- rnorm(500)
y1 <- sample(c("a", "b", "c"), 500, replace=T)
boxplot(x1 ~ y1)
text(x= 1, y= 3, labels= "some text")
text(x= 2, y= 3, labels= "more \n text")
text(x= 3, y= 3, labels= "red text", col= "red")

enter image description here

like image 197
Alex W Avatar answered Jan 12 '23 11:01

Alex W