这可能是很明显的事情,但是我很难找到一个很好的资源来解释如何使用gwidgets的特性。在一些帮助下,我有了这个脚本,它创建了复选框,该复选框可以更改文件名列表,然后使用ggplot创建选中文件的图。问题是,这个阴谋被切断在正确的边缘,我不知道如何解决这个问题。
编辑:我看到你们中的一些人一直在忙着贬低我,但是现在如果你用我提供的文件运行它,这个方法就能工作了。我怀疑这个问题是由cairoDevice和ggraphics呈现情节的方式引起的。
read.table("foo.csv", header = TRUE, sep = ",", row.names=1)
ggplot(MeanFrameMelt, aes(x=variable, y=value, color=Legend, group=Legend))+
geom_line()+
theme(panel.background = element_rect(fill='NA', colour='black', size = 1),
legend.position = "none")+
ylab("Tag Density (mean coverage/bp)")+
xlab("Distance from reference side (bp)")+
scale_x_discrete(breaks=c("V1", "V200", "V400"), labels=c("-10000", "0", "10000"))+
GraphFiles <- FileNamesOrig
w <- gwindow("Tag Density Checkboxes", width = 1000)
g <- ggroup(container = w, horizontal = FALSE)
add(g, ggraphics())
lyt <- glayout(container = g, horizontal = FALSE)
print(p)foo.cvs (这是MeanFrameMelt)

编辑2: --这就是图对我来说的样子。我不知道发生了什么,我使用以下命令导出data.frame:
write.table(MeanFrameMelt, file="test.cvs", sep=",", col.names=TRUE)但是,当我使用导出的文件运行它时,我得到的正是agstudy得到的。文件应该是相同的。

编辑3:
用gput测试它(谢谢您的建议),现在它创建了正确的情节:新文件
使用dget(file="test.txt")
发布于 2013-01-12 09:52:11
我刚刚重组了你的代码,但我不能重现问题。您必须调用handelr中的绘图操作,以便稍后与用户交互(例如,缩放、鼠标事件)。我在这里举一个例子。当你第一次运行时,你有一个丑陋的轴的情节。然后,当您在区域中单击时,图将被刷新,并且有一个很好的轴。
## I define my plot
p <- ggplot(MeanFrameMelt, aes(x=variable, y=value, color=Legend, group=Legend))+
geom_line()+
theme(panel.background = element_rect(fill='NA', colour='black', size = 1),
legend.position = "none")+
ylab("Tag Density (mean coverage/bp)")+
xlab("Distance from reference side (bp)")
## init gwidgets
library(gWidgetsRGtk2)
w <- gwindow("Tag Density Checkboxes", width = 1000)
g <- ggroup(container = w, horizontal = FALSE)
gg <- ggraphics(container=g)
lyt <- glayout(container = g, horizontal = FALSE)
## I plot it the first time
print(p)
## I add a handler
ID <- addHandlerChanged(gg, handler=function(h,...) {
p <- p + scale_x_discrete(breaks=c("V1", "V200", "V400"),
labels=c("-1000", "0", "1000"))
print(p)
})
print(p)

https://stackoverflow.com/questions/14282384
复制相似问题