Iâ€™ve drawn figure in R with lwd=1, e.g.

pdf(â€˜test.pdfâ€™)plot(1:10, type=â€™oâ€™, lwd=2, axes=F)

box(lwd=1, col=â€™redâ€™)

dev.off()

And then you open the PDF in Illustrator, you will see the border width is 0.75pt, and the line is 1.5pt, which seems that **the unitÂ of 1 in R is 0.75pt in Illustrator**.

How is this defined? Where can I change it?

I found the answer by switching the display unit of stroke in Illustrator (see below) from point to inch. It shows **1point=1pixel=0.0139inch=1/72 inch in Illustrator.**

And in the R document of

points(), Â it says:

ValueÂ `pch = "."`

Â (equivalentlyÂ `pch = 46`

) is handled specially. It is a rectangle of side 0.01 inch (scaled byÂ `cex`

). In addition, ifÂ `cex = 1`

Â (the default), each side is at least one pixel (1/72 inch on theÂ `pdf`

,Â `postscript`

Â andÂ `xfig`

Â devices).

For other text symbols,Â `cex = 1`

Â corresponds to the default fontsize of the device, often specified by an argumentÂ `pointsize`

. ForÂ `pch`

Â inÂ `0:25`

Â the default size is about 75% of the character height (seeÂ `par("cin")`

).

So, when saved into pdf, a point without scaling in R is oneÂ rectangleÂ with one pixel each side, also 1/72 inch, which means the size of basic unit of R and illustrator should be same. But why lwd=1 will result in 0.75pt=3/4pixel in Illustrator? Is it set in PDF output?

OK. The answer is already in the

pdf() document:

Line widths as controlled byÂ `par(lwd = )`

Â are in multiples of 1/96 inch. Multiples less than 1 are allowed.Â `pch = "."`

Â withÂ `cex = 1`

Â corresponds to a square of side 1/72 inch, which is also the ‘pixel’ size assumed for graphics parameters such asÂ `"cra"`

.

So, lwd=1 is equal to 1/96 inch, which is exactly as 0.75 * 1/72 inch (0.75pt). To change it, for example if we want to set line width as 0.5 pt in Illustrator, we can set lwd=2/3, as below:

pdf(â€˜test2.pdfâ€™)

par(lwd=2/3)

plot(1:10, type=â€™oâ€™)

dev.off()

But I found this does not control the line width of axis and legend, which have to be set in the function itself.

btw, I have not figured it out how to get same setting for stroke line in R and in Illustrator. I was setting lty=â€™32â€™, lwd=2/3 in R, assuming that I can get stroke line as dash=1.5pt and gap=1pt in Illustrator, but actually I did not. Donâ€™t know why. If anyone can figure it out, please let me know.

*Related*

To

**leave a comment** for the author, please follow the link and comment on their blog:

** One Tip Per Day**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as:

Data science,

Big Data, R jobs, visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...