The ggiraph
package is both an HTML widget and a ggplot2
extension. There are a bunch of things you can do with it: design hover effects, set hover information, program JavaScript actions to trigger on click, and enable zoom. Changes such as these are mainly conducted under two families of functions: *_*_interactive()
and ggiraph()
. This recipe is about to introduce the usage of the last two, but once you get used to the stat/geom dynamic on ggplot2
, the same logic is applied to ggiraph
.
A recipe does not come without data, and this is coming from the DAAG
package. We're using the races2000
data set (Scottish Hill Races Data - 2000) to plot record time against distance. The race type will be displayed by colors, while record time in hours for females will be available by mouse hovering. Of course, all of that will be achieved using ggiraph
:
> if(!require(DAAG)){install.packages('DAAG')} > if(!require(devtools)){install.packages...