[R] device "mismatch", coordinates trouble with X11 and pdf devices

Paul Johnson pauljohn32 at gmail.com
Sat Aug 11 07:53:21 CEST 2012


Greetings.

I'm trying to understand a problem on a Dell Laptop.  Details below,
also uploaded the R working example that I pasted below.

http://pj.freefaculty.org/scraps/testSymbols.R

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C                 LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


## Paul Johnson <pauljohn at ku.edu>
## 2012-08-10
##
## I've got trouble with a mis-match between screen and pdf devices.
## Please run this and tell me if the point z's "marker" is on the
## intersection of the 2 circles for you.

## Why do I ask? On my Dell M4600 laptop, the marker (the pch=12) is
## on the intersection in the x11 device. See the screenshot:
##
## http://pj.freefaculty.org/scraps/testSymbol-01.png
##
## But the pdf output of same is not
##
## http://pj.freefaculty.org/scraps/testSymbol.pdf
##
## Notice one other weird thing. The circle sizes change. Maybe
## that's just the same weird thing.

## The X11 device is 7in x 7in. Right? Same as pdf.
## Why would coordinates from locator work in one display, but not the
## other?  I've abused the symbols function somehow? locator is device
## dependant?

## Maybe its the video driver & LCD.
## This is a Dell Precision M4600. The LCD display is 13.6 inches x
## 7.6 inches (345.4mm x 193mm). By my reckoning, it is not precisely
## 16:9.  The Nvidia card says the native resolution is 1920x1080,
## which is exactly 16:9.




saveFile <- FALSE
if(saveFile){
pdf(file="testSymbol.pdf", onefile=FALSE, paper="special", height = 7,
width = 7)
}

plot(c(0,1), c(0,1), type = "n", xlab = "", ylab = "")


x <- c(0.3, 0.3)
y <- c(0.7, 0.7)
points(x[1], x[2])
points(y[1], y[2])

symbols(x[1], x[2], circles=c(0.3), lty=2, inches = FALSE, add=TRUE)

symbols(y[1], y[2], circles=c(0.3), lty=2, inches = FALSE, add=TRUE)

##Here's what I get from locator(1) on the intersection
z <- list(x=0.4028, y=0.6485)
if (is.null(z)) z <- locator(1) ## click on intersection of lines


points(z, pch=12)
text(x =0.96*z[[1]], y = 1.05*z[[2]], label="z")

dev.off()




-- 
Paul E. Johnson
Professor, Political Science    Assoc. Director
1541 Lilac Lane, Room 504     Center for Research Methods
University of Kansas               University of Kansas
http://pj.freefaculty.org            http://quant.ku.edu



More information about the R-help mailing list