作为脚本运行时,ggplot无输出 [英] No output from ggplot when running as a script

查看:103
本文介绍了作为脚本运行时,ggplot无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉打扰您一个肯定是非常简单的错误,但是我仍然无法自己解决这个问题:

Sorry to bother you with what is for sure a very simple mistake, but I still cannot figure it out by myself:

library(ggplot2)

X = rep(c(1:6),3)
Y = rep(c(1:6),3)
group = rep(c(1:3), each = 6)

data = data.frame(X = X, Y = Y, group = group)

ggplot(data, aes(x = X, y = Y, group = group)) + geom_point() 

作为脚本运行时,我没有得到任何输出-没有创建任何图形.我在这里做什么错了?

I do not get any output from this when I run as a script -- no figure is created. What am I doing wrong here?

推荐答案

如果从其他函数或Shiny中调用该图,请尝试打印该图:

Try print the plot if you are calling it from another function or in Shiny:

myplot <- ggplot(data, aes(x = X, y = Y, group = group)) + geom_point() 

print(myplot)

这篇关于作为脚本运行时,ggplot无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆