Robert Baer
2012-Jun-05 15:12 UTC
[R] ggplot2, grid graphics, x11(), windows(), and device fonts
I am trying to use ggplot() to produce a graph and am getting warnings that I don't understand. This is happening from within RStudio, but also happens if I start Windows R GUI. Can anyone help me understand the warning and how to make sure the right fonts are designated? The relevant code fragment is: x11(width=7, height = 7) library(ggplot2) # Now some Distance ~ Time plots p2 <- ggplot(lu.mig, aes(x=Time, y=Net.Distance, colour = PlateRow)) + geom_point(size= 3) + geom_line(size=1) + facet_grid(Substrate ~ Expression) + xlab("Time After Scratch (h)") + ylab("Net half-distance (um)") + opts(title='Repaired Raw 1205Lu Scratch Time Course') + theme_bw(base_size = 18, base_family = "") print(p2) The warnings are: There were 22 warnings (use warnings() to see them)> > warnings()Warning messages: 1: Removed 1 rows containing missing values (geom_point). 2: Removed 1 rows containing missing values (geom_path). 3: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : Font family not found in Windows font database 4: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : Font family not found in Windows font database ... snip ... # repeat same warning 22: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), ... : Font family not found in Windows font database If I comment out, x11(width=7, height = 7) so that the plot is drawn to the RStudio graphics device (or the default device in R GUI), I only get the expected first two warnings. As I have traced through the documentation I've seen reference to an 'Rdevga? that may be a culprit, but I can't quite understand how I set this up properly. Any debugging pointers? It also seems that if I replace x11() with windows(), the warnings disappear. Somewhere (wrongly, I guess) I had gotten the impression that x11() on the windows platform behaved just like windows(). For now, I've just reverted to using windows(), but I'd like to understand this better, particularly how to be certain ggplot() (or grid()) will be able to find a default font. Of course, despite the warnings the graph draws fine so it could be something to evaluation in ggplot. Thanks, Rob> R.Version()$platform [1] "i386-pc-mingw32" $arch [1] "i386" $os [1] "mingw32" $system [1] "i386, mingw32" $status [1] "" $major [1] "2" $minor [1] "15.0" $year [1] "2012" $month [1] "03" $day [1] "30" $`svn rev` [1] "58871" $language [1] "R" $version.string [1] "R version 2.15.0 (2012-03-30)" $nickname [1] "" C:\Users\rbaer>path PATH=C:\Perl\site\bin;C:\Perl\bin;C:\Program Files\GTK\bin;C:\Program Files\ImageMagick-6.7.6-Q16;C:\Program Files\Mende ley Desktop\wordPlugin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;c:\Rtools\bin;c:\Rtools\perl\bin;c:\R tools\MinGW\bin;c:\Rtools\MinGW64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Window sPowerShell\v1.0\;C:\Program Files\Microsoft Application Virtualization Client;C:\Program Files\WIDCOMM\Bluetooth Softwa re\;C:\Program Files\Windows Live\Shared;C:\Program Files\MiKTeX 2.9\miktex\bin\;C:\Program Files\QuickTime\QTSystem\;C: \GTK\bin; ------------------------------------------ Robert W. Baer, Ph.D. Professor of Physiology Kirksville College of Osteopathic Medicine A. T. Still University of Health Sciences 800 W. Jefferson St. Kirksville, MO 63501 660-626-2322 FAX 660-626-2965