막대 플롯과 cowplot을 사용하여 점 플롯을 결합하려고하면 오류가 발생합니다. 요청에 따라 작업 예제를 작성해 볼 수는 있지만, 명백한 문제를 발견 할 수 있는지 먼저 알 수 있다고 생각했습니다.cowplot을 사용하여 플롯을 가리 키기 위해 cowplot을 사용하여 막대 플롯 (stat = identity)을 사용합니다. 오류
다음 막대 그래프의 코드 생성 플롯이다
가dodge=position_dodge(width=0.9)
pbar <- ggplot(data = dat,aes(x=npnts,y=power,fill=PrpSurvPerYr)) +
geom_bar(aes(fill=PrpSurvPerYr),stat="identity",colour="black",position=dodge) +
geom_hline(yintercept=80,linetype="dotted",size=1) +
ylab("Power") + xlab("Number of points per transect") +
scale_fill_manual(values = c("white","gray","black")) +
scale_y_continuous(breaks=seq(0,100,by=20)) +
theme(axis.text.x=element_text(size=20)) +
theme(axis.text.y=element_text(size=20)) +
theme(axis.title.x=element_text(size=30)) +
theme(axis.title.y=element_text(size=30)) +
geom_text(aes(label=ntrns),vjust=-0.3,size=8,position=dodge)+
labs(fill="% transects \nsurveyed \nper year") +
theme(legend.title=element_text(size=20)) +
theme(legend.text=element_text(size=18))
는 다음 점 플롯 코드 및 생성 된 플롯이다 같이
ptrd <- ggplot(data = dat.plt,aes(x=X,y=med)) +
geom_point(size=3,alpha=0.3) +
geom_errorbar(aes(ymin=lo,ymax=hi),width=0.003,alpha=0.3) +
geom_hline(yintercept=0.98,linetype="dotted") +
scale_y_continuous(breaks=c(0.98)) +
scale_x_continuous(breaks=c()) +
ylab(expression(hat(lambda)[psi])) + xlab(NULL) +
theme(axis.text.x=element_blank()) +
theme(axis.title.x=element_blank()) +
theme(axis.title.y=element_text(size=35)) +
theme(axis.text.y=element_text(size=26))
Point plot 다음 두 가지를 함께 꿰매려고했습니다.
p <- ggdraw() +
draw_plot(pbar, x = 0, y = 0, width = 1, height = .0.75) +
draw_plot(ptrd, x = 0, y = 0.75, width = 1, height = .25)
불행히도, "알 수없는 상수"에 관한 오류가 발생하며 허용되는 콘솔 공간에 과부하가 걸리는 출력이 뒤 따르기 때문에 오류를 잘 볼 수 없습니다.
모든 아이디어를 얻을 수 있습니다.
이 부분을 _minimal_ 및 _reproducible_ 만들 수 있습니까? 먼저, 플롯 ('dat'과'dat.plt')에 대한 약간의 데이터를 공유하십시오. 아마도 전부는 아니지만 오류를 재생하기에 충분할 것입니다. 그런 다음 라벨 및 테마 설정과 같이 오류가 표시되지 않도록 모든 내용을 플롯에서 제거하십시오. 또한 여기 좀 봐 : [위대한 R 재현 가능한 예제를 만드는 방법?] (http://stackoverflow.com/questions/5963269) – Axeman