ggpomological icon indicating copy to clipboard operation
ggpomological copied to clipboard

another solution for `paint_pomological`

Open GuangchuangYu opened this issue 6 years ago • 3 comments

library(ggpomological)
basic_iris_plot <- ggplot(iris) +
  aes(x = Sepal.Length, y = Sepal.Width, color = Species) +
  geom_point(size = 2)

basic_iris_plot <- basic_iris_plot + scale_color_pomological()
pomological_iris <- basic_iris_plot + theme_pomological_fancy()

library(ggimage) ## `geom_image`, `geom_subview` and `theme_transparent`

ggplot(d=data.frame(x=0:1, y=0:1), aes(x, y)) + 
    geom_image(image=ggpomological:::pomological_images("background"),size=Inf) + 
    geom_subview(subview= pomological_iris+ theme_transparent(), width=Inf, height=Inf, x=.5, y=.5) +
    theme_void()

The output is still gg object.

PS: I am the author of ggimage.

GuangchuangYu avatar Apr 18 '18 04:04 GuangchuangYu

I create a shortcut in ggimage, now we can use ggbackground to add any background image for a gg object.

ggbackground(pomological_iris, ggpomological:::pomological_images("background"))

ggbackground introduction.

GuangchuangYu avatar Apr 18 '18 05:04 GuangchuangYu

oooh I like this, thanks for letting me know!

gadenbuie avatar Apr 18 '18 14:04 gadenbuie

Excellent! The ggbackground function makes my life easier! One question a bit unrelated: when I save as a pdf the pomological iris, regardless of the aspect ratio, the "g" of length and the "p" of petal are cut at the border. Is this expected? Any remedy for that?

larry77 avatar Aug 26 '18 20:08 larry77