Learn R Programming

ggiraph (version 0.3.1)

geom_point_interactive: add points with tooltips or click actions for a scatterplot

Description

The point_interactive geom is used to create interactive scatterplots, tooltips can be displayed when mouse is over points, on click actions can be set with javascript instructions.

Usage

geom_point_interactive(mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...)

Arguments

mapping
The aesthetic mapping, see geom_point.
data
A data frame, see geom_point.
stat
The statistical transformation to use on the data for this layer, as a string, see geom_point.
position
Postion adjustment, see geom_point.
na.rm
show.legend
inherit.aes
...
other arguments passed on to layer. See geom_point.

See Also

ggiraph

Examples

Run this code
# add interactive points to a ggplot -------
# create dataset
dataset = iris
dataset$tooltip = dataset$Species
dataset$clickjs = paste0("alert(\"",dataset$Species, "\")" )

# plots
gg_point = ggplot(dataset, aes(x = Sepal.Length, y = Petal.Width,
		color = Species, tooltip = tooltip, onclick = clickjs) ) +
	geom_point_interactive()

ggiraph(code = {print(gg_point)})

Run the code above in your browser using DataLab