if (FALSE) {
iris.mds <- stats::cmdscale(dist(iris[, 1:4]), k = 2)
mds.df <- setNames(
cbind(iris.mds, data.frame(iris$Species)),
c("dim1", "dim2", "Species")
)
result <- catSpatInterp(
mds.df, x.col = "dim1", y.col = "dim2", group.col = "Species",
num.grid = 300, knn = 20, hull.buffer = 0.05,
num.cores = 5, num.batches = NULL
)
library(ggplot2)
ggplot(mapping = aes(dim1, dim2)) +
geom_raster(
aes(fill = Species, alpha = prob),
data = result$raster
) +
geom_polygon(data = result$hull.poly, fill = NA, col = "black") +
geom_hline(yintercept = 0, col = "white") +
geom_vline(xintercept = 0, col = "white") +
geom_point(
aes(fill = Species),
data = mds.df,
col = "black",
shape = 21,
size = 4
) +
theme(
axis.ticks = element_blank(),
axis.text = element_blank(),
axis.title = element_blank(),
legend.position = "top",
panel.grid = element_blank(),
panel.background = element_blank()
)
}
Run the code above in your browser using DataLab