I can not figure out how to use .gif figures as points in x-y plotting, and rotate each point according to data in the dataset.
Demo dataset:
library("ggplot2")
library("ggimage")
N=5
d <- data.frame(x = rnorm(N),
y = rnorm(N),
image = rep("https://www.r-project.org/logo/Rlogo.png", N),
size = seq(.05, 0.15, length.out = N),
angle = seq(0, 45, length.out = N) )
The follwing will make a plot where all Rlogo's are rotated 45 degrees:
ggplot(d, aes(x, y)) +
geom_image(aes(image=image, size=I(size)), angle = 45)
# Plot with tilted png
But how to set the rotation angle individually for each point? The snippet below simply does not work and makes a plot without tilting any points..
ggplot(d, aes(x, y)) +
geom_image(aes(image=image, size=I(size), angle = I(angle)))
#plotting but without tilting the points
Setting the plot angle outside the aes does not help.
ggplot(d, aes(x, y)) + geom_image(aes(image=image, size=I(size)), angle = I(d$angle))
# No plotting: Error in valid.viewport(x, y, width, height, just, gp, clip, xscale, yscale, invalid 'angle' in viewport
So, anyone having a good idea for this? Thanks in advance:-)