Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R基本包网格不产生输出_R_Amazon Ec2_Windows Server 2008 - Fatal编程技术网

R基本包网格不产生输出

R基本包网格不产生输出,r,amazon-ec2,windows-server-2008,R,Amazon Ec2,Windows Server 2008,我正在Windows Server 2008 R2 Amazon EC2实例上运行64位R2.15.0网格不产生输出。例如,以下代码应在设备窗口中生成一条对角线: grid.newpage() l <- linesGrob() grid.draw(l) grid.newpage() 可以调用ldev.list()来返回开放图形设备的命名向量。例如,在Windows上: windows() pdf() dev.list() # windows pdf # 2

我正在Windows Server 2008 R2 Amazon EC2实例上运行64位R2.15.0<代码>网格不产生输出。例如,以下代码应在设备窗口中生成一条对角线:

grid.newpage()
l <- linesGrob()
grid.draw(l)
grid.newpage()
可以调用l
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)
windows()
grid.newpage()
可以调用l
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)
windows()
grid.newpage()

l
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()
库(ggplot2)
图书馆(网格)
图书馆(地图)
图书馆(mapproj)
图书馆(png)
图书馆(RgoogleMaps)

无法通过远程桌面连接在Windows设备中正确生成光栅图像。如果需要光栅图像,则必须将打印输出到其他设备

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()
库(ggplot2)
图书馆(网格)
图书馆(地图)
图书馆(mapproj)
图书馆(png)
图书馆(RgoogleMaps)


我不熟悉EC2上的Windows映像,但在运行linux实例时,我认为默认的图形设备是pdf,它将输出保存到Rplots.pdf。请参阅
?设备
,然后尝试
选项(“设备”)
。在linux实例上,如果我想与绘图更具交互性,我通常会通过ssh转发X11(尽管这有时会很慢)。否则,我将围绕调用
plot()
grid.draw()
,使用
pdf(file=“file1.pdf”)
dev.off()
,稍后通过在远程服务器上查看图像文件(sftp、ftp等)的常规方式访问pdf。是否打印(1)做你想做的吗?@jthetzel在save命令和off之间包装绘图只会产生一个空白图像。@mdsumner
plot(1)
按预期工作将详细信息放入q中以改进它,目前它还不完整我不熟悉EC2上的Windows图像,但在运行linux实例时,我认为默认的图形设备是pdf,将输出保存到Rplots.pdf。请参阅
?设备
,然后尝试
选项(“设备”)
。在linux实例上,如果我想与绘图更具交互性,我通常会通过ssh转发X11(尽管这有时会很慢)。否则,我将围绕调用
plot()
grid.draw()
,使用
pdf(file=“file1.pdf”)
dev.off()
,稍后通过在远程服务器上查看图像文件(sftp、ftp等)的常规方式访问pdf。是否打印(1)做你想做的?@jthetzel在save命令和off之间包装绘图只会产生一个空白图像。@mdsumner
plot(1)
按预期工作将细节放入q中以改进它,目前它是incomplete@jhetzel谢谢你的回复,但这并没有解决问题,也没有给我任何关于其原因的线索。我在原来的问题上加了一个更好的例子。我的实际目标是使用
grid
ggplot2
图形绘制.png背景。我可以在我的个人电脑和工作电脑之间来回复制代码,让它完美运行。在EC2上,我得到了
ggplot2
部分(实际图形),但背景是空白的。@station\u-stool:您使用的是哪种设备?您是否尝试过使用pdf或png设备,然后将生成的图像文件复制回您的家庭或工作计算机?这有助于验证EC2实例上的网格包是否存在问题,而不是EC2上的Windows设备或PDF viewer是否存在问题。@jhetzel如果设备存在问题,为什么要渲染其余的绘图?在任何情况下,我尝试了所有的设备,得到了所有设备的空白输出。@attitude\u stool:Fair point。也许你可以发布
sessionInfo()
,尽管我认为这不会透露什么。
grid::drawGrob(l)
是否产生任何结果?晶格工作正常吗:
xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width | Species,data=iris)
@attitude\u凳子:还有一件事:
print(grid.draw(l))
?@jhetzel感谢您的回复,但这并没有解决问题,也没有给我任何关于其原因的线索。我在原来的问题上加了一个更好的例子。我的实际目标是使用
grid
ggplot2
图形绘制.png背景。我可以在我的个人电脑和工作电脑之间来回复制代码,让它完美运行。在EC2上,我得到了
ggplot2
部分(实际图形),但背景是空白的。@station\u-stool:您使用的是哪种设备?您是否尝试过使用pdf或png设备,然后将生成的图像文件复制回您的家庭或工作计算机?这有助于验证EC2实例上的网格包是否存在问题,而不是EC2上的Windows设备或PDF viewer是否存在问题。@jhetzel如果设备存在问题,为什么要渲染其余的绘图?在任何情况下,我尝试了所有的设备,得到了所有设备的空白输出。@attitude\u stool:Fair point。也许你可以发布
sessionInfo()
,尽管我认为这不会透露什么。
grid::drawGrob(l)
是否产生任何结果?晶格工作正常吗:
xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width | Species,data=iris)
@attitude\u凳子:还有一件事:
print(grid.draw(l))
?你不需要弄乱
面板。背景来获得背景图像,尤其是没有网格线。您只需使用
?注释\u光栅
?注释\u自定义
即可。您不需要