这是我的 GUI“标题”:
library(gWidgets2RGtk2)
library(cairoDevice)
library(ggplot2)
WINGRAPH0 <- gwindow("")
WINGRAPH <- gvbox(container=WINGRAPH0)
以下代码不起作用:
gnb <- gnotebook(container=WINGRAPH)
ggraph <- ggraphics(container=gnb)
ggplot(cars, aes(x=speed, y=dist)) + geom_point()
它给:
Error in UseMethod("depth") :
no applicable method for 'depth' applied to an object of class "NULL"
但是,如果我首先在图形笔记本中显示图像文件,则效果很好:
gnb <- gnotebook(container=WINGRAPH)
gimage("plot1.png", container=gnb)
ggraph <- ggraphics(container=gnb)
ggplot(cars, aes(x=speed, y=dist)) + geom_point()
在第一个代码中,如果我使用经典图而不是 ggplot(例如plot(0,0)
),我会得到:
Error in plot.new() : figure margins too large
我已经尝试了这个问题的答案,但没有奏效。