r의 격자 패키지를 사용하여 누적 분포 함수를 나타내는 막대 그래프와 xyplot을 겹치기를 원합니다.히스토그램과 xyplot을 겹치기
사용자 패널 기능으로이 작업을 수행하려고 시도했지만 올바른 결과를 얻지 못하는 것 같습니다. 한 변이가 단 변이이고 한 변이가 두 변이라고 생각합니다.
는 여기에 수직으로 쌓아 원하는 두 개의 플롯과 예입니다 :
set.seed(1)
x <- rnorm(100, 0, 1)
discrete.cdf <- function(x, decreasing=FALSE){
x <- x[order(x,decreasing=FALSE)]
result <- data.frame(rank=1:length(x),x=x)
result$cdf <- result$rank/nrow(result)
return(result)
}
my.df <- discrete.cdf(x)
chart.hist <- histogram(~x, data=my.df, xlab="")
chart.cdf <- xyplot(100*cdf~x, data=my.df, type="s",
ylab="Cumulative Percent of Total")
graphics.off()
trellis.device(width = 6, height = 8)
print(chart.hist, split = c(1,1,1,2), more = TRUE)
print(chart.cdf, split = c(1,2,1,2))
나는 이러한 동일한 프레임에서 중첩보다는 스택 싶습니다.
제 1, 작업도 내가 시도 그것의 간단한 변형을 수행하지 않는 코드 다음 더 나은 응답이 올 때까지이xyplot(cdf~x,data=cdf,
panel=function(...){
panel.xyplot(...)
panel.histogram(~x)
})
+1 - 나는 이것이 꽤 좋은 대답이라고 생각합니다. 때때로 간단한 해결책이 필요한 것입니다. – thelatemail