I'm trying to implement one of the answers in this question
I'm using the third answer, the one with the function new_legend.
Here's my output.
I cannot share the data. Just think of it as columns in data.frames: df1, df2, df12.
The code that produces the image is the following:
add_legend <- function(...) {
opar <- par(fig=c(0, 1, 0, 1), oma=c(0, 0, 0, 0),
mar=c(0, 0, 0, 0), new=TRUE)
on.exit(par(opar))
plot(0, 0, type='n', bty='n', xaxt='n', yaxt='n')
legend(...)
}
op <- par(cex = 1)
#bc
plot(df1[,2],df2[,1],xlab="save",ylab="log85",ylim=c(6, 10))
#bc2
points(df1[,2],df2[,3],xlab="save",ylab="log85",col=2)
#od
points(df1[,2],df1[,1],pch=3,col=3)
#od2
points(df12[,2],df12[,1],pch=3)
add_legend("top", legend=c("too big text", "description with","a lot of" ,"useless freespace"),
col=c(1, 2,3,1),pch=c(1,1,3,3),horiz=TRUE, bty='n', x.intersp = 0.3)
I would like to put the legend with less free space between descriptions and with a bigger font size. I've tried using x.intersp
but it just diminishes the distance between the symbol and its description, and not the distance between a previous description and the next symbol. If I use par(cex=1)
before doing the plot, then the font size is good, but more text is clipped.
Any help would be appreciated.