How to resize PDF graphics created in R using Illustrator

I make graphs in R using the pdf() command. The graphs look great and change well in Acrobat Reader. My normal workflow involves manipulating shortcuts, etc. In Illustrator, saving as .eps for sending to publishers or pasting into Word. Everything works fine for individual schedules.

Now I am trying to combine 4 columns into one, manually combining them in an A4 Illustrator document. However, when I resize a standard 7x7 inch graphic in Illustrator to fit on a single column of an A4 page (about 3.4 inches wide), all the proportions are screwed, for example. the lines and outlines of characters become too thick. Using pdf(..., width=3.4, height=3.4) in R messed up all the sizes of the characters and fonts that were carefully chosen to create the original graph. Why can't I resize the graph in Illustrator the same way I can resize pdf, for example. in Acrobat Reader?

+4
source share
1 answer

Illustrator scales everything, including the stroke thickness, used to draw lines and characters that were converted to paths, and the font size for any text not converted to paths. (Since I don't have Illustrator, I cannot say whether Illustrator treats β€œtext” as text or as a path when opening pdf.)

When Adobe Acrobat Reader displays pdf, it just shows the rasterized view of the current file, so it just scales everything as you want.

I see two options; Either create a 2x2 graph directly in R and export it to PDF with the correct size, or reduce the margins and font size used on each graph and export them with the required width / height using the command you showed.

The first parameters can be achieved with:

 pdf("attempt1.pdf", ....) layout(matrix(1:4, ncol = 2, byrow = FALSE)) ## byrow = TRUE for fill-by-row ## all 4 plot calls go in here layout(1) dev.off() 

You may need to adjust the dot size used in the pdf() device and adjust the cex.??? settings a cex.??? for some bits of the graph, to set it up exactly the way you want it.

Alternatively, you need to reduce the size and margins and draw each chart on a 3.4-inch device. Something like this will let you get started:

 pdf("attempt2.pdf", height = 3.4, width = 3.4, pointsize = 10) op <- par(mar = c(4,3,3,1) + 0.1) ## one line less per marging ## your single plotting call here par(op) dev.off() 

See ?par for a list of ways to manage graph fields and other parameters that you might want to configure to control the quality of the final graph. You might want to examine the cex.foo options to control the relative size of the text in the graphs, but this is all relative to the base value that you set when creating the pdf() device.

+3
source

Source: https://habr.com/ru/post/1432439/


All Articles