I am trying to use ggplot
and ggimage
to create a 3D scatterplot with a custom image. It works fine in 2D:
library(ggplot2)
library(ggimage)
library(rsvg)
set.seed(2017-02-21)
d <- data.frame(x = rnorm(10), y = rnorm(10), z=1:10,
image = 'https://image.flaticon.com/icons/svg/31/31082.svg'
)
ggplot(d, aes(x, y)) +
geom_image(aes(image=image, color=z)) +
scale_color_gradient(low='burlywood1', high='burlywood4')
I've tried two ways to create a 3D chart:
-
plotly - This currently does not work with geom_image, though it is queued as a future request.
-
gg3D - This is an R package, but I cannot get it to play nice with custom images. Here is how combining those libraries ends up:
library(ggplot2)
library(ggimage)
library(gg3D)
ggplot(d, aes(x=x, y=y, z=z, color=z)) +
axes_3D() +
geom_image(aes(image=image, color=z)) +
scale_color_gradient(low='burlywood1', high='burlywood4')
Any help would be appreciated. I'd be fine with a python library, javascript, etc. if the solution exists there.
from 3D scatterplot using custom image
No comments:
Post a Comment