ggimage
ggimage copied to clipboard
image legend key
#!/bin/env Rscript
library(ggimage)
set.seed(2018-12-11)
d <- data.frame(x=1:10, y=1:10,
type = sample(LETTERS[1:3], 10, replace=T),
angle = runif(10, 0, 360))
options(ggimage.keytype = "point")
ggplot(d, aes(x, y, colour=type, angle=angle)) +
geom_pokemon(aes(image=ifelse(x>5, 'pikachu', 'tauros')))
windows()
options(ggimage.keytype = "rect")
ggplot(d, aes(x, y, colour=type, angle=angle)) +
geom_pokemon(aes(image=ifelse(x>5, 'pikachu', 'tauros')))
windows()
options(ggimage.keytype = "image")
ggplot(d, aes(x, y, colour=type, angle=angle)) +
geom_pokemon(aes(image=ifelse(x>5, 'pikachu', 'tauros')), angle=45)
For legend key of image color, I implemented three optional keytypes:
- solid circle dots ❤️
- rectangle 👍
- image (the R logo, similar to text color legend that use
) 😄
Which one do you prefer?
❤️ for 1, 👍 for 2 and for 😄 for 3, please click the emoji icon to vote for it.
Please comment on it if you have any other idea!
😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄😄
good
I prefer the dots... only if it's not possible to have the images themselves in the legend :wink:
@maelle personally, I also prefer the dots. The images used in the plot cannot be used in the legend, as we cannot use the text in the plot as legend. There can be several different images that belong to the same category and have identical color. None of them are suitable.
Why not make dot the default behavior and allow users to override the shapes as well?
@teng-gao dot is indeed the default.