[英]Legend is apears in the wrong place in the page (R): not fully shown
我已将以下命令添加到 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)
然而,图例出现在情节之外并没有完全显示,
如果您在更改title
功能"topleft"
到"topright"
和删除inset
的说法,你的标题应该是指示确定。 请看下面的代码:
# simulation
set.seed(123)
tdf <- as.data.frame(matrix(rbinom(20, 15, .4) * 8, ncol = 4))
# draw the plot
colours <- 2:6
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("topright", c("M1","M2","M3","M4","M5", "M6"), cex=0.6,xpd=TRUE, fill=colours)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.