R 未考虑堆放面积(ggplot2)和NA
我正在使用R 未考虑堆放面积(ggplot2)和NA,r,plot,ggplot2,na,stacked-area-chart,R,Plot,Ggplot2,Na,Stacked Area Chart,我正在使用ggplot2软件包绘制物种丰度的堆积区域 我的代码: #Aggragate 2 column x=IBTS[,3:4] Datehour=paste(IBTS$Date.,IBTS$Time.) Date<-strptime(Datehour,"%d/%m/%Y %H:%M") #Add a new column with the date IBTS$Date IBTS<-cbind(IBTS,Date) #Plotting t
ggplot2
软件包绘制物种丰度的堆积区域
我的代码:
#Aggragate 2 column
x=IBTS[,3:4]
Datehour=paste(IBTS$Date.,IBTS$Time.)
Date<-strptime(Datehour,"%d/%m/%Y %H:%M")
#Add a new column with the date
IBTS$Date
IBTS<-cbind(IBTS,Date)
#Plotting the data
p<-ggplot(IBTS,aes(x=Date,y=Number.of.Particles.))
p+geom_area(aes(fill=Selection.set.),position="stack")+
theme_bw()+ scale_fill_brewer(palette="Blues")
#第二栏
x=IBTS[,3:4]
Datehour=粘贴(IBTS$日期,IBTS$时间)
日期投诉似乎是“Janv.30”处应该有空白,因为那里缺少数据geom_area
基于GeomRibbon
,我在GitHub上发布了一个导致这种情况发生的bug。Hadley实际上现在刚刚修复了它,但是版本当然没有发布
我昨天在这个链接上发布了一个解决方案
更新
在我让你创建一个新的geom来解决这个问题之前,现在我发现了一条做同样事情的单线:
GeomRibbon$handle_na <- function(data, params) { data }
p<-ggplot(IBTS,aes(x=Date,y=Number.of.Particles.))
p+geom_ribbon_na(aes(fill=Selection.set.),position="stack")+
theme_bw()+ scale_fill_brewer(palette="Blues")
GeomRibbon$handle\u na我根据插入的限制创建了两行空数据,解决了这个问题。现在,新的插入已经在这个地方形成了一个“空白”区域。我只想感谢您的帮助您能提供一个吗?什么叫“未考虑”?你想有一个不连续(一个白色的差距)?似乎重复阿根尼斯问,我会有这个短期内的不连续性,并会有同样的结果在上一个链接。我尝试使用geom_ribbon函数,但我从未构建过循环…可能是OP当时正在抱怨一个新的ggplot2
bug。不确定这里的问题是什么,但是如果他应该在有插值的地方有空白(空白),那么检查这个。