How To Convert A Human To Waves By Magick Package

November 23, 2018

I saw this tweet about Mathematica last year, which naturally urged me to write the R version of this code. Mathematicaを使って,シュレーディンガーの顔をこのようなアニメーションにされたユーザの方がいらっしゃいます。コードも掲載されています。 — Wolfram Japan (@WolframJapan) June 15, 2017 At that time, I faild because I didn’t know how to zoom images. But, now I know magick package. Let’s try again… Zoom images by magick We can enlarge a image by either image_resize(), image_scale(), or image_sample(). I don’t know about the details of the differences, but it seems image_resize() does better for my purpose. ... Read more

geom_sf_text() and geom_sf_label() Are Coming!

October 10, 2018

ggplot2 v3.1.0 will be released soon (hopefully), so let me do a spoiler about a small feature I implemented, geom_sf_label() and geom_sf_text(). How can we add label/text with geom_sf()? geom_sf() is one of the most exciting features introduced in ggplot2 v3.0.0. It magically allows us to plot sf objects according to their geometries’ shapes (polygons, lines and points). But, for plotting them as some other shapes than the original ones, we cannot rely on geom_sf() so it needs a bit of data transformation beforehand. ... Read more

gghighlight 0.1.0 Is Released!

July 4, 2018

gghighlight 0.1.0 is on CRAN now! New features As I’ve introduced on the previous post, gghighlight now can highlight any Geoms with gghighlight(). Since this function supersedes the previous functions, gghighlight_line() and gghighlight_point() are now deprecated. A Vignette One more small news is, gghighlight got an introductory vignette. This is basically the shorter version of the previous post: Introduction to gghighlight

Re-introduction to gghighlight: Highlight ggplot2 with Predicates

June 16, 2018

Half a year ago, I’ve introduced gghighlight package. I didn’t expect so much R people get interested in my package. Thanks for your attention! But, please forget about that gghighlight; gghighlight has become far more powerful and simple! So, let me re-introduce about gghighlight. (Note that this version of gghighlight is not yet on CRAN at the time of this writing. Please install by devtools::install_github("yutannihilation/gghighlight") for the time being) ... Read more

Plot geom_sf() On OpenStreetMap Tiles

June 9, 2018

mapview is a very nice package to explore an sf object. It can overlay sf object on the map images: nc <- sf::read_sf(system.file("shape/nc.shp", package="sf")) mapview::mapview(nc) But, how can I do this with ggplot2? (My friend told me mapview::mapshot() can generate a PNG, but I want to do this with ggplot2!) RTFM Before anything, I need to read Tile Usage Policy to use the OpenStreetMap tiles. For “Requirements” section, this is important: ... Read more

Anatomy of gghighlight

June 3, 2018

I’m overhauling my gghighlight package toward the upcoming release of ggplot2 2.3.0. I think I will introduce about the new gghighlight() soon, but before that, I want to write out the ideas behind gghighlight. Note that what I’ll write here contains few new things, as the basic idea is already covered by this great post: Plotting background data for groups with ggplot2 My post is mainly for organizing my thought, yet I hope someone find this useful :) ... Read more

An Example Usage of ggplot_add()

November 7, 2017

A generic function ggplot_add() was added to ggplot2 by this PR: Allow addition of custom objects by thomasp85 · Pull Request #2309 · tidyverse/ggplot2 I think creating a custom Geom or Stat and its constructor (geom_*() or stat_*()) is enough for the most of the extension packages of ggplot2, but some people, including me, need this. Why are there no geom_highlight()? Here is an example code of my package gghighlight: ... Read more

Introduction to gghighlight: Highlight ggplot's Lines and Points with Predicates

October 6, 2017

(Update: The functions introduced here is deprecated now. Please use gghighlight(), which is far nicer one) Suppose we have a data that has too many series like this: set.seed(2) d <- purrr::map_dfr( letters, ~ data.frame(idx = 1:400, value = cumsum(runif(400, -1, 1)), type = ., stringsAsFactors = FALSE)) For such data, it is almost impossible to identify a series by its colour as their differences are so subtle. ... Read more