如何在图例中设置文字大小?

时间:2015-09-18 14:06:54

标签: r plot

我试过这个

#!/usr/bin/R

fcm <-c(13.0,12.5,11.8)
gk  <-c(10.9 ,   10.5  ,  10.2)
gg  <-c(12.0 ,   11.0 ,   10.8)
data1 <- rbind(fcm,gk,gg)
colnames(data1) <- c(5,6,7)

barplot(as.matrix(data1),ylim=c(0,15),main="P wave",
        xlab="number of clusters",ylab="traveltime rms(ms)",
        col=c("red", "black", "green"), beside=TRUE)
op <- par(cex=.64)
legend(legend = c("fcm","gk","gg"), fill = c( "red", "black", "green"), 
"top", horiz=TRUE,text.font=3)
par(op)

dev.copy(png,"s1.png",width=4,height=4,units="in",res=200)
dev.off()

当图像出现时,R图形设备2活动看起来很好。但保存图像在图例中有重叠的单词。 enter image description here

如何解决这个问题?

1 个答案:

答案 0 :(得分:4)

您可以在“绘制”之前致电dev.copy,而不是使用png保存图片:

png("Z:/GES - catalogue signatures/biblio/cdf pour Wolf/s1.png", width=4,height=4,units="in",res=200)
barplot(as.matrix(data1),ylim=c(0,15),main="P wave",
         xlab="number of clusters",ylab="traveltime rms(ms)",
         col=c("red", "black", "green"), beside=TRUE)
op <- par(cex=.64)
legend(legend = c("fcm","gk","gg"), fill = c( "red", "black", "green"), 
 "top", horiz=TRUE,text.font=3)
par(op)
dev.off()

enter image description here