[R-SIG-Mac] odd behavior and error messages when using text()

Eric Pante amelia.and.eric at gmail.com
Mon Mar 1 20:30:32 CET 2010


Dear listers,

I would like to report an issue I had today, while plotting text on a  
map.
I am using Mac OS 10.5.8 and R 2.10.1 (same problem with R and R64.  
Plus, see sessionInfo below).

The map is based on the data in the "maps" library.
The plotted text corresponds to concatenated text and numbers; the  
data coming from a csv spreadsheet.

In addition to the error messages reported below, the plotted text has  
a font that looks very crude, and exporting the map as a PDF results  
in a file > 48 MB that crashes Preview and Acrobat. I did tests for  
which only the map was plotted (no problem), and only points were  
plotted (no problem, although the font of the points is not as smooth  
as it could be).

I did a search on the R list for the error message I received, with no  
success. However, I did find some mac-related posts that have to do  
with Cocoa development, so this probably is a mac-related issue (the  
answer to these posts were completely over my head, unfortunately...)

In the error message, I replaced the address of my computer by  
"ADDRESS".

 > read.csv("METADATA_SPB_COORD_02-01-10.csv", header=T)  ->  
metadata.coord.cd
 > library(maps) ; states <- data.frame(map("state", plot=FALSE) 
[c("x","y")])
 > plot(states,type="l", xlim=c(-105,-72), ylim=c(25,40))
 >
 > for(i in 1:length(metadata.coord.cd[,1])){
+ 	t = paste(metadata.coord.cd$St.name,metadata.coord.cd$CD.num,sep="")
+  	text(metadata.coord.cd$CENTER.LONG, metadata.coord.cd$CENTER.LAT,  
t, cex=0.7)
+  	}
Mon Mar  1 13:02:38 ADDRESS R[489] <Error>: CGContextSetFont: invalid  
context
Mon Mar  1 13:02:38 ADDRESS R[489] <Error>: CGContextSetFontSize:  
invalid context
Mon Mar  1 13:02:38 ADDRESS R[489] <Error>: CGContextGetFont: invalid  
context

 > sessionInfo()
R version 2.10.1 (2009-12-14)
x86_64-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] maps_2.1-0

loaded via a namespace (and not attached):
[1] tools_2.10.1


Insights would be much appreciated!
Best regards, eric pante



More information about the R-SIG-Mac mailing list