I have added the following command to the plot in R:
df<- read.table("filename.csv", header=TRUE, sep=",", stringsAsFactors=FALSE)
tdf=as.data.frame(df[2:ncol(df)])
# draw the plot
bb<- barplot(as.matrix(tdf), beside=T ,
col=colours,border="black", ylim=c(0,100), ylab="Percentage (%)",xlab="Methods)")
y<-as.matrix(tdf)
text(bb,y+2,labels=as.character(y),pos =1,offset=3,cex = 0.6, col = "black")
legend("topleft", c("M1","M2","M3","M4","M5", "M6"), cex=0.6,inset=c(1,0),xpd=TRUE, fill=colours)
However, the legend appears outside of the plot and not fully shown,
I want it to be seen outside right side of plot. I do not understand the positioning here
If you change in
title
function"topleft"
to"topright"
and removeinset
argument you title should be indicated OK. Please see the code below:Output: