Maxwell Chandler
Maxwell Chandler

Reputation: 642

Putting labels on points when there is no y-axis in R

I have 11 values which I created with the following code:

ken <- c(0,0,0,0,0,0,0,0,0,0,0)
ken[1] <-cor(q6,q7,method="kendall")
ken[2]<-cor(q6,q7,method="kendall")
ken[3] <-cor(q6,q8,method="kendall")
ken[4] <-cor(q6,q9,method="kendall")
ken[5] <-cor(q6,q10,method="kendall")
ken[6] <-cor(q7,q8,method="kendall")
ken[7] <-cor(q7,q9,method="kendall")
ken[8] <-cor(q7,q10,method="kendall")
ken[9] <-cor(q8,q9,method="kendall")
ken[10] <-cor(q8,q10,method="kendall")
ken[11] <-cor(q9,q10,method="kendall")
# here are the resulting values:
ken <- c(0.655565129645506, 0.655565129645506, 0.665566263923066, 0.626515492412177, 
         0.461715156391015, 0.571235224489538, 0.417032490161232, 0.406244490689434, 
         0.600130074947292, 0.60706951258355, 0.390576151134331)

I then plot them.

plot(~ken, xlab="correlation values", ylab="")
abline(v=.5)

enter image description here

I am trying to add labels to this plot with the following code:

text(c(ken[1:11]), labels=c("q6*q7","q6*q7","q6*q8","q6*q9","q6*q10","q7*q8","q7*q9",
                            "q7*q10","q8*q9","q8*q10","q9*q10"), srt=90, cex=1, col="black")

This code produces no labels (or at least does not put them on the plot). I know how to put labels on a plot that has a y-axis, but this plot has none. I would like to keep the graph exactly how it is, just adding labels.

Upvotes: 1

Views: 37

Answers (1)

gung - Reinstate Monica
gung - Reinstate Monica

Reputation: 11903

By default, the plotted y-value is 1. FWIW, you don't need the cex=1 or col="black" arguments—they do nothing.

windows()
  plot(~ken, xlab="correlation values", ylab="")
  abline(v=.5)
  text(c(ken[1:11])+.005, 1.06, srt=90, labels=c("q6*q7","q6*q7","q6*q8","q6*q9",
       "q6*q10","q7*q8","q7*q9","q7*q10","q8*q9","q8*q10","q9*q10"))

enter image description here

Upvotes: 2

Related Questions