Determine the size of the drawing elements in mm (R)

I am preparing numbers in R for submission to the magazine. The required formatting is indicated in mm (line width = 0.5 mm, characters = 3 mm, etc.).

I know how to define the size of the figure in mm and also control the line width and size of the character with lwd and cex respectively, either in the par () parameter or inside the plot function. I also found how to convert points to mm. However, I don't know how to determine the line weight, text size, etc. Precisely, not "scaling" as usual (for example, I want lwd = 0.5mm, not lwd = 1.2x by default).

I hope I'm clear enough =)

Here is my code:

jpeg(paste('path-to-figure.jpg'), width=15, height=7)

plot(x, y, main = 'TITLE', xlab = "X NAME",ylab = 'Y NAME', ylim = c(0,180), xlim = c(0, 4)pch = 1)

dev.off()

      

Many thanks!

+3


source to share


1 answer


Line width in standard jpeg

, png

etc. graphics devices are defined in 1/96 inches. See https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/png.html . The same is true for pdf

, but may be different for other devices. 0.5 mm = 0.5 / 25.4 * 96 = 1.890 96 thousand inches. This way you would use lwd = 1.89

.

You can also use ggplot2

, since size

within, which is mm anyway.



eg.

ggplot(my_data, aes(x, y)) + geom_line(size = 0.5)

      

+1


source







All Articles