Permalink
Browse files

Apply scale transformations before and after calling function in stat…

…-function
  • Loading branch information...
chrisalice committed Dec 3, 2012
1 parent ee45226 commit aec144ac5be00f78f8938fe4ba8aa6811f2c4eb1
Showing with 4 additions and 1 deletion.
  1. +4 −1 R/stat-function.r
View
@@ -54,10 +54,13 @@ StatFunction <- proto(Stat, {
calculate <- function(., data, scales, fun, n=101, args = list(), ...) {
range <- scale_dimension(scales$x, c(0, 0))
xseq <- seq(range[1], range[2], length=n)
+ x_v = if (is.null(scales$x)) xseq else scales$x$trans$inverse(xseq)
+ y_v = do.call(fun, c(list(x_v), args))
+ y = if (is.null(scales$y)) y_v else scales$y$trans$transform(y_v)
data.frame(
x = xseq,
- y = do.call(fun, c(list(xseq), args))
+ y = y
)
}
})

0 comments on commit aec144a

Please sign in to comment.