【R】ggfx
2021年3月3日
1. はじめに
ggfxは、ggplot2の拡張機能です。
2. インストール
githubからインストールします。
devtools::install_github('thomasp85/ggfx')
3. 使ってみる。
3.1 With関数
library(ggfx)
library(ggplot2)
ggplot(mtcars, aes(x = disp, y = qsec, fill=hp)) +
with_blur(
geom_point(),
sigma = unit(1, 'mm')
) +
geom_smooth()

3.2 レイヤーの重ね合わせ
volcano_raster <- as.raster((volcano - min(volcano)) / diff(range(volcano)))
ggplot() +
with_blend(
geom_text(aes(x = 3.5, y = 3.5, label = '🚀GGFX🚀'), size = 15),
bg_layer = volcano_raster,
blend_type = 'copy_green',
alpha = 'src'
)

4. さいごに
このパッケージはかなり多くの拡張機能を提供してくれます。magickも使っているようなので、使いこなせればかなりの表現力がありそうです。