Mohamed Lajnef
2012-Feb-02 13:07 UTC
[R] Draw vertical line segments between pairs of points
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20120202/9218c644/attachment.pl>
On 02/03/2012 12:07 AM, Mohamed Lajnef wrote:> Dear all, > > How to add /*vertical*/ lines above bar graph to display p-values ( > between pairs of points )? >Hi Mohamed, The "segments" function will do this, but I'm not quite sure of what you want to display. Let's say you have a bar plot like this: heights<-c(2,6,3,5,4,7) xpos<-barplot(heights,ylim=c(0,10),main="The Bar Plot", names.arg=c("First","Second","Third","Fourth","Fifth","Sixth")) The centers of the bars are now in "xpos", and the heights of the bars are in "heights". To draw vertical lines of one unit length above each bar: segments(xpos,heights,xpos,heights+1) If you want to display p-values above each bar: text(xpos,heights+1.1, paste("p=",c(0.09,0.003,0.07,0.007,0.05,0.001),sep="")) Is that the idea? Jim