Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.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 使用geom_smooth时是否可以绕过stat_smooth?_R_Ggplot2 - Fatal编程技术网

R 使用geom_smooth时是否可以绕过stat_smooth?

R 使用geom_smooth时是否可以绕过stat_smooth?,r,ggplot2,R,Ggplot2,我有一个数据集,我构建了以下图表: 该图由本文底部包含的数据集提供,并由以下ggplot2代码生成: ggFacetProfile <- ggplot(sub, aes(group = iMoYr)) + geom_line(aes(x= iHrMi, y = trimAv)) + facet_grid(off ~ iMoYr, scales = "free") + ggtitle("Typical Half Hourly Profiles") +

我有一个数据集,我构建了以下图表:

该图由本文底部包含的数据集提供,并由以下ggplot2代码生成:

    ggFacetProfile <- ggplot(sub, aes(group = iMoYr))  + 
    geom_line(aes(x= iHrMi, y = trimAv)) + 
    facet_grid(off ~ iMoYr, scales = "free") +
    ggtitle("Typical Half Hourly Profiles") + 
    xlab("Time") + ylab("Energy (kWh)")
但是,这被强制为黄土平滑,显然是由于数据的大小,如下所示:

是否可以输入特定于geom_smooth的预先计算值,或者我是否试图以错误的方式使用geom_smooth?ggplot2中的其他geom_uuu参数具有如此强的适应性,这似乎是不一致的

出于结构目的,数据源(数据表)的开头和结尾包括在下面:

          iDate            off       trimAv   trimStD minEcl maxEcl   iMoYr iHrMi
   1: 2013-08 00:00     Production 136.52273 37.300389   76.4  218.4 2013-08 00:00
   2: 2013-08 00:30     Production 136.14091 36.117819   80.3  217.7 2013-08 00:30
   3: 2013-08 01:00     Production 133.92500 32.808662   76.9  213.3 2013-08 01:00
   4: 2013-08 01:30     Production 139.20476 37.929480   77.1  221.5 2013-08 01:30
   5: 2013-08 02:00     Production 137.82857 36.422042   74.9  221.0 2013-08 02:00
  ---                                                                             
1148: 2014-07 22:30 Non-Production  50.51250  3.025812   47.1   56.3 2014-07 22:30
1149: 2014-07 23:00 Non-Production  49.88571  2.066743   47.0   52.6 2014-07 23:00
1150: 2014-07 23:30 Non-Production  49.94286  2.318661   46.5   52.5 2014-07 23:30
1151: 2014-07 00:00 Non-Production  50.85714  2.860569   47.9   54.9 2014-07 00:00
1152: 2014-07 00:30 Non-Production  50.72857  4.181194   47.6   59.1 2014-07 00:30

如果我能以更好/更合适的形式包含源数据,请在评论中告诉我。

也许您正在寻找
geom\u ribbon

ggFacetProfile <- ggplot(sub, aes(group = iMoYr))  + 
  geom_line(aes(x= iHrMi, y = trimAv)) + 
  facet_grid(off ~ iMoYr, scales = "free") +
  ggtitle("Typical Half Hourly Profiles") + 
  xlab("Time") + ylab("Energy (kWh)") +
  geom_ribbon(aes( ymin = minEcl, ymax = maxEcl))

对不起,我不明白你的目标是什么:你想用geom_smooth做什么?也许您只需要为
方法
-参数设置一个值?您是想在每个trimStD点周围显示minEcl和maxEcl作为着色,还是想先使用minEcl和maxEcl平滑上下点,然后显示着色?也许您可以尝试
geom_ribbon
<代码>+geom_smooth(aes(x=iHrMi,ymin=minEcl,ymax=maxEcl)),可能与
geom_线条一起
?@WaltS,抱歉,我的标题似乎有误,现在将修复并编辑以澄清。在上面的评论中,当然应该是
geom_ribbon(aes(x=iHrMi,ymin=minEcl,ymaxecl))
,而不是geom_smooth
ggFacetProfile <- ggplot(sub, aes(group = iMoYr))  + 
  geom_line(aes(x= iHrMi, y = trimAv)) + 
  facet_grid(off ~ iMoYr, scales = "free") +
  ggtitle("Typical Half Hourly Profiles") + 
  xlab("Time") + ylab("Energy (kWh)") +
  geom_ribbon(aes( ymin = minEcl, ymax = maxEcl))