### simple names<-c("Adam", "Alice", "Brian", "Barbara", "Charles", "Carla", "Christina", "David") sex<-c("M","F","M","F","M","F","F","M") ages<-c(18, 19, 22, 21, 20, 29, 20, 19) heights<-c(167.5, 160, 170.5, 154, 179, 166, 158, 160.5) sex.as.number <-NULL for (i in 1:8) ifelse(sex[i] == "M", sex.as.number[i]<-1, sex.as.number[i]<-2) colours1<-c("blue","deeppink") par(mfrow=c(1,2)) plot(NULL, axes=F, xlim=c(0,2), ylim=c(min(heights),max(heights)), xlab="", ylab="Height (cm)", main="My friends’ heights") axis(2, c(150, 155, 160,165, 170, 175, 180),at=c(150, 155, 160,165, 170, 175, 180), xpd=NA) text (c(rep(1.3,8)), heights, names, col=colours1[sex.as.number],adj=1) for (i in 1:8){ arrows(0.65, heights[i], 0, heights[i], code = 2, col=colours1[sex.as.number[i]], lwd=2, length=0.07) } ### adjusting arrows and changing font plot(NULL, axes=F, xlim=c(0,2), ylim=c(min(heights),max(heights)), xlab="", ylab="Height (cm)", main="My friends’ heights") axis(2, c(150, 155, 160,165, 170, 175, 180),at=c(150, 155, 160,165, 170, 175, 180), xpd=NA) text (c(rep(1.3,8)), heights, names, col=colours1[sex.as.number],adj=1, family= "mono") name_lengths<-c(nchar(names))## a vector of numbers of character in each name arrow_starts<-1.3-(name_lengths/9.5) # 9.5 found by trial anderror for (i in 1:8){ arrows(arrow_starts[i], heights[i], 0, heights[i], code = 2, col=colours1[sex.as.number[i]], lwd=2, length=0.07) }