次のコードそれらは必ずしも実際のデータ点(補間することができる)ではないですが、離間多かれ少なかれ均等にポイントを加算し、
barbedize <- function(x, y, N=10, ...){
ind <- order(x)
x <- x[ind]
y <- y[ind]
lengths <- c(0, sqrt(diff(x)^2 + diff(y)^2))
l <- cumsum(lengths)
tl <- l[length(l)]
el <- seq(0, to=tl, length=N+1)[-1]
res <-
sapply(el[-length(el)], function(ii){
int <- findInterval(ii, l)
xx <- x[int:(int+1)]
yy <- y[int:(int+1)]
dx <- diff(xx)
dy <- diff(yy)
new.length <- ii - l[int]
segment.length <- lengths[int+1]
ratio <- new.length/segment.length
xend <- x[int] + ratio * dx
yend <- y[int] + ratio * dy
c(x=xend, y=yend)
})
as.data.frame(t(res))
}
library(plyr)
few_points <- ddply(transData, "Type", function(d, ...)
barbedize(d$Value, d$ecd, ...), N=10)
ggplot(transData, aes(x=Value, y=ecd)) +
geom_line(aes(group=Type,colour=Type, linetype=Type), size=1) +
geom_point(aes(x=x,y=y, colour=Type, shape=Type), data=few_points, size=3)
(これは、素早く汚れた原理証明であり、barbedize
はきれいになり、より効率的に書かなければなりません...)
プロットが経験的な累積分布関数(ecdf)である場合、軸名が示唆するように、プロットの左下に垂直セグメントが存在しない(右上に1つ、他のグループに1つあります)多くの「0」または「1」の値に対応する2つの垂直線分(左下および左上)に点がないことは奇妙に見える(「ecd」列が[0、 1])。 –