R basic equipment does not produce output

I am running 64-bit R 2.15.0 on an instance of Amazon EC2 for Windows Server 2008 R2. griddoes not display the result. For example, the following code should create one diagonal line in the device window:

grid.newpage()
l <- linesGrob()
grid.draw(l)

However, I do not see anything. Is there a flag or parameter that I should use in Windows Server 2008 R2 to enable grid output?

EDIT: Another reproducible example that works in my home (Windows 7 x64) and on work PCs (Windows XP):

library(grid)
library(png)

img.path <- system.file("img", "Rlogo.png", package="png")
bg <- readPNG(img.path)
background <- rasterGrob(unclass(bg))

grid.draw(background)

This is the expected result, as seen on my working PC (modified to match below):

R-log-png

+2
source share
2 answers

R . , .

library(ggplot2)
library(grid)
library(maps)
library(mapproj)
library(png)
library(RgoogleMaps)

counties <- map_data("county", region="virginia")
states <- map_data("state")

tmp <- tempfile(fileext=".png")
bg <- GetMap.bbox(range(counties$long), range(counties$lat), destfile=tmp, 
     maptype="satellite", format="png32")
background <- readPNG(tmp)
background <- rasterGrob(unclass(background))

p <- ggplot(counties, aes(long, lat)) +
   coord_map(xlim=c(bg$BBOX$ll[2], bg$BBOX$ur[2]), 
             ylim=c(bg$BBOX$ll[1], bg$BBOX$ur[1])) +
   geom_path(aes(group=group), color="darkgrey") +
   geom_path(data=states, aes(group=group), color="white", size=1) +
   opts(axis.line=theme_blank(),
        axis.text.x=theme_blank(),
        axis.text.y=theme_blank(),
        axis.ticks=theme_blank(),
        axis.title.x=theme_blank(),
        axis.title.y=theme_blank(),
        axis.ticks.length=unit(0, "lines"),
        axis.ticks.margin=unit(0, "lines"),
        panel.border=theme_blank(),
        panel.background=function(...)background,
        panel.grid.major=theme_blank(),
        panel.grid.minor=theme_blank(),
        panel.margin=unit(0, "lines"),
        legend.position="none",
        legend.title=theme_blank(),
        legend.background=theme_blank(),
        plot.margin=unit(0*c(-1.5, -1.5, -1.5, -1.5), "lines"))

pdf("plot.pdf", height=7, width=7)
p
dev.off()

, pdf() dev.off() . .

+2

dev.list() , . Windows, :

windows()
pdf()
dev.list()
# windows     pdf 
#       2       3 
dev.off(); dev.off()
dev.list()
# NULL

dev.cur() . , :

windows()
grid.newpage()
l <- linesGrob()
grid.draw(l)

pdf , pdf :

pdf() # plot saved by default to Rplots.pdf
grid.newpage()
l <- linesGrob()
grid.draw(l)
dev.off() 

?device . grid.newpage() , , , , . Windows 7 x64 Ubuntu 11.10 x64.

@attitude_stool: - ?

+2

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


All Articles