문제

Sample data/example:

x <- log(seq(1,11,1))
y <- seq(0,1,0.1)
plot <- xyplot(y~x, type="l")
update(plot, panel = function(...) {
panel.xyplot(...)})+as.layer(xyplot(y[3]~x[3], type=c("p"), lwd=3, cex=3, pch=3))

Now, lets say that I have a new measurement of point where my function x outputs value above the 2.5, something like number 10. I have to keep the initial plot axis at y=0:1 and x=0:2,5.

How can I show graphically that the value is outside its range to plot? Its there a way to tell/show that the value 10 exists?

I just thought about this:

ifelse(x > 2.5, 2.5) 

which would bring the value 10 to 2,5 and draw the point at the end of the function x. Is there a way to "draw" - show outliers?

The real case is more complicated so hence this simplification. Hint as to where to look would be also helpful.

EDIT: Solution posted by TWL gave me hint within lattice:

tp <- sprintf("+ outlier")

mypanel<-function(x,y,...){
panel.xyplot(x, y, ...)
panel.text(2,1,labels=tp,cex=1.5,col="red")}

xyplot(y~x, type="l", panel=mypanel)
도움이 되었습니까?

해결책

May I suggest an alternative, possibly easier than using lattice:

x <- log(seq(1,11,1))
y <- seq(0,1,0.1)

# set the margins and 'xpd' allows to plot outside the range
par(mar=c(5,5,5,7), xpd=T)

# plot the data within the range
plot(x,y, type="l", col="blue", frame=F, xlim=c(0,2.5))
points(x[3],y[3], col="blue", pch=3, cex=2)

# add the outlier by specifying the coordinate x and/or y outside the range
points(2.9, 1, col='blue', pch=20, cex=2)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top