Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in interpolation? #47

Open
ugroempi opened this issue Feb 7, 2021 · 0 comments
Open

Possible bug in interpolation? #47

ugroempi opened this issue Feb 7, 2021 · 0 comments

Comments

@ugroempi
Copy link

ugroempi commented Feb 7, 2021

Hi Nick,
thanks for providing ggtern. I have tried to use it for visualizing a 3D Dirichlet density with the code below. The behavior of the function should be completely symmetric with respect to the three variables. However, the code produces a non-symmetric picture. (Swapping variable names x1 and x3 leaves the anomality between x1 and x2, so it must be the interpolation that does this.) To me, this looks like a bug in the interpolation behavior. Or am I doing something wrong?
Best, Ulrike

`require(gtools)
require(ggplot2)
require(ggtern)

x1 <- c(0.0001, seq(0.01,0.99,0.01), 0.9998)
x2 <- c(0.0001, seq(0.01,0.99,0.01), 0.9998)
x3 <- c(0.0001, seq(0.01,0.99,0.01), 0.9998)

mat <- as.matrix(expand.grid(x1,x2,x3))
colnames(mat) <- c("x1","x2","x3")
mat <- mat[rowSums(mat)==1,]
dichte <- gtools::ddirichlet(x=mat, rep(0.5,3))
mat <- as.data.frame(cbind(100*mat, dichte=dichte))
ggtern(data=as.data.frame(mat), aes(x=x1,y=x2,z=x3, value=dichte)) +
stat_interpolate_tern(method = "loess", bins=2000)
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant