Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.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 仅选择一些面以在面_包裹、ggplot2中打印_R_Ggplot2_Facets - Fatal编程技术网

R 仅选择一些面以在面_包裹、ggplot2中打印

R 仅选择一些面以在面_包裹、ggplot2中打印,r,ggplot2,facets,R,Ggplot2,Facets,我的问题很简单,但我多次尝试都没能解决。我只想打印一个刻面图的一些刻面(用ggplot2中的刻面_wrap制作),然后删除我不感兴趣的刻面 我使用ggplot2进行了面_包裹,如下所示: #anomalies linear trends an.trends <- ggplot()+ geom_smooth(method="lm", data=tndvilong.anomalies, aes(x=year, y=NDVIan, colour=TenureZone,

我的问题很简单,但我多次尝试都没能解决。我只想打印一个刻面图的一些刻面(用ggplot2中的刻面_wrap制作),然后删除我不感兴趣的刻面

我使用ggplot2进行了面_包裹,如下所示:

#anomalies linear trends
an.trends <- ggplot()+
  geom_smooth(method="lm", data=tndvilong.anomalies, aes(x=year, y=NDVIan, colour=TenureZone,
                                                     group=TenureZone))+
  scale_color_manual(values=miscol) + 
  ggtitle("anomalies' trends")

#anomalies linear trends by VEG
an.trendsVEG <- an.trends + facet_wrap(~VEG,ncol=2)
print(an.trendsVEG)
#异常线性趋势

a.trends我建议最简单的方法就是给
ggplot()
一个合适的子集。在这种情况下:

facets <- c("CenKal_ShWoodl", "HlShl_ShDens", "NKal_ShWoodl", "ThShl_ShDens")
an.trends.sub <- ggplot(tndvilong.anomalies[tndvilong.anomalies$VEG %in% facets,])+
  geom_smooth(method="lm" aes(x=year, y=NDVIan, colour=TenureZone,
                                                     group=TenureZone))+
  scale_color_manual(values=miscol) + 
  ggtitle("anomalies' trends") +
  facet_wrap(~VEG,ncol=2)

facets这真的很好用,真的很感谢。现在我试着在图中加入每一行的R^2值,这样我就可以比较趋势的不同。我在网上找到的所有解决方案都建议计算方程式,并将结果添加到数据集中,然后绘制它们。我想知道ggplot2是否只是为了添加这些信息而有一个论点。我想说,如果您找到的所有解决方案都告诉您相同的事情,那么这里有一条消息。。。但无论哪种方式,对我来说都是一个单独的问题——如果答案解决了你的问题,别忘了接受它