1
私はコマンドラインから動作するコードがあります。 RStudioからピース単位で実行すると、正常に動作します。コマンドラインから実行するとグラフィックデバイスが開きますが、空白のままです。コマンドラインからコードを起動しました:グラフィックデバイスの空白
require(ggplot2)
#ds <- head(SOM_dist_tot)
num <- 6
ds <- c(1.00566799, 0.81354614, 0.36507594, 0.15541231, 0.13957369, 0.06986632)
vett <- as.data.frame(ds)
pdf("ggplot_test.pdf")
gioele <-ggplot(vett, aes(x= as.numeric(rownames(vett)), y =vett$ds))+
geom_point(size=2) + xlab("X") + ylab("Y")+
ggtitle("...")+
theme(axis.text.x = element_text(angle=-45, hjust=0, vjust=1),
plot.margin = unit(c(1, 1, 1, 1), "cm"),
plot.title = element_text(size = 20, face = "bold", colour = "black", vjust = -1))
#print(gioele)
plot(gioele)
dev.off()
print(gioele)
inputFromUser <- as.numeric(readLines(file("stdin"),1))
dev.off()
グラフ「gioele」を表示して、ユーザーに情報を提供したいとします。その後、ユーザは挿入するコマンドを選択し(inputFromUser
)、ウィンドウを閉じる必要があります。 アイデアはありますか?
多分[ggsave](http://docs.ggplot2.org/0.9.2.1/ggsave.html)を見てください。なぜあなたはプロット(gg2)を使用していますか、印刷されていないのでしょうか(gg2)? – zx8754
私は可能な組み合わせをたくさん試しました。私はplot(gg2)、print(gg2)、gg2のみを試しました(この場合は無視され、ウィンドウはポップアップしません)。私はggsaveを見て、私はあなたに知らせるでしょう。ありがとう! –