ggiraph v0.7.0


Monthly downloads



Make 'ggplot2' Graphics Interactive

Create interactive 'ggplot2' graphics using 'htmlwidgets'.



Travis Build
Status AppVeyor Build
Status Coverage
Status CRAN\_Status\_Badge

Make ‘ggplot’ Graphics Interactive


ggiraph is a tool that allows you to create dynamic ggplot graphs. This allows you to add tooltips, animations and JavaScript actions to the graphics.The package also allows the selection of graphical elements when used in shiny applications.

Under the hood, ggiraph is an htmlwidget and a ggplot2 extension. It allows graphics to be interactive, by exporting them as SVG documents and using special attributes on the various elements.

Interactivity is added to ggplot geometries, legends and theme elements, via the following aesthetics:

  • tooltip: tooltips to be displayed when mouse is over elements.
  • onclick: JavaScript function to be executed when elements are clicked.
  • data_id: id to be associated with elements (used for hover and click actions)

Why using ggiraph

  • You want to provide your readers with more information than the basic information available; you can display a tooltip when the player’s mouse is on a graphical element, you can also visually animate elements with the same attribute when the mouse passes over a graphical element, and finally you can link a JavaScript action to the click, such as opening a hypertext link.
  • You want to allow users of a Shiny application to select graphical elements; for example, you can make the points of a scatter plot selectable and available as a reactive value from the server part of your application. With Shiny, ggiraph allows interaction with graph elements, legends elements, titles and ggplot theme elements from the server part; each selection is available as a reactive value.


With R and R Markdown

The things you need to know to create an interactive graphic :

  • Instead of using geom_point, use geom_point_interactive, instead of using geom_sf, use geom_sf_interactive… Provide at least one of the aesthetics tooltip, data_id and onclick to create interactive elements.
  • Call function girafe with the ggplot object so that the graph is translated as a web interactive graphics.
data <- mtcars
data$carname <- row.names(data)

gg_point = ggplot(data = data) +
    geom_point_interactive(aes(x = wt, y = qsec, color = disp,
    tooltip = carname, data_id = carname)) + 

girafe(ggobj = gg_point)

Usage within Shiny

  • If used within a shiny application, elements associated with an id (data_id) can be selected and manipulated on client and server sides. The list of selected values will be stored in in a reactive value named [shiny_id]_selected.

Available interactive layers

They are several available interactive geometries. They are all based on their ggplot version, same goes for scales and the few guides: geom_point_interactive(), geom_col_interactive(), geom_tile_interactive(), scale_fill_manual_interactive(), scale_discrete_manual_interactive(), guide_legend_interactive(), …


Get development version on github


Get CRAN version



Online documentation

The help pages are located at

Getting help

If you have questions about how to use the package, visit Stackoverflow and use tags ggiraph and r Stackoverflow link! I usually read them and answer when possible.

Contributing to the package

Bug reports

When you file a bug report, please spend some time making it easy for me to follow and reproduce. The more time you spend on making the bug report coherent, the more time I can dedicate to investigate the bug as opposed to the bug report.

Contributing to the package development

A great way to start is to contribute an example or improve the documentation.

If you want to submit a Pull Request to integrate functions of yours, provide if possible:

  • the new function(s) with code and roxygen tags (with examples)
  • a new section in the appropriate vignette that describes how to use the new function
  • corresponding tests in directory tests/testthat.

By using rhub (run rhub::check_for_cran()), you will see if everything is ok. When submitted, the PR will be evaluated automatically on travis and appveyor and you will be able to see if something broke.

Functions in ggiraph

Name Description
geom_polygon_interactive Create interactive polygons
geom_sf_interactive Create interactive sf objects
guide_colourbar_interactive Create interactive continuous colour bar guide
geom_smooth_interactive Create interactive smoothed conditional means
geom_abline_interactive Create interactive reference lines
guide_legend_interactive Create interactive legend guide
geom_density_interactive Create interactive smoothed density estimates
geom_raster_interactive Create interactive raster rectangles
geom_density_2d_interactive Create interactive contours of a 2d density estimate
geom_rect_interactive Create interactive rectangles
geom_path_interactive Create interactive observations connections
geom_point_interactive Create interactive points
geom_jitter_interactive Create interactive jittered points
opts_toolbar Toolbar settings
interactive_polygon_grob Create interactive polygon grob
geom_ribbon_interactive Create interactive ribbons and area plots
geom_segment_interactive Create interactive line segments
interactive_roundrect_grob Create interactive rectangle grob
interactive_segments_grob Create interactive segments grob
opts_tooltip Tooltip settings
geom_map_interactive Create interactive polygons from a reference map
interactive_polyline_grob Create interactive polyline grob
girafe_css CSS creation helper
scale_size_interactive Create interactive scales for area or radius
geom_errorbarh_interactive Create interactive horizontal error bars
girafeOutput Create a girafe output element
geom_freqpoly_interactive Create interactive histograms and frequency polygons
geom_quantile_interactive Create interactive quantile regression
girafe Create a girafe object
scale_colour_interactive Create interactive colour scales
interactive_points_grob Create interactive points grob
renderggiraph Reactive version of ggiraph object
run_girafe_example Run shiny examples and see corresponding code
interactive_raster_grob Create interactive raster grob
girafe_options Set girafe options
GeomInteractive ggproto classes for ggiraph
geom_label_interactive Create interactive textual annotations
label_interactive Create an interactive label
opts_selection Selection effect settings
opts_hover Hover effect settings
scale_alpha_interactive Create interactive scales for alpha transparency
interactive_rect_grob Create interactive rectangle grob
scale_linetype_interactive Create interactive scales for line patterns
scale_manual_interactive Create your own interactive discrete scale
scale_colour_brewer_interactive Create interactive colorbrewer scales
ggiraph Create a ggiraph object
interactive_parameters Interactive parameters
interactive_path_grob Create interactive path grob
interactive_text_grob Create interactive text grob
ggiraphOutput Create a ggiraph output element
scale_gradient_interactive Create interactive gradient colour scales
scale_shape_interactive Create interactive scales for shapes
opts_sizing Girafe sizing settings
opts_zoom Zoom settings
scale_viridis_interactive Create interactive viridis colour scales
renderGirafe Reactive version of girafe
annotation_raster_interactive Create interactive raster annotations
geom_contour_interactive Create interactive 2d contours of a 3d surface
element_interactive Create interactive theme elements
geom_crossbar_interactive Create interactive vertical intervals: lines, crossbars & errorbars
dsvg_view Run plotting code and view svg in RStudio Viewer or web broswer.
annotate_interactive Create interactive annotations
geom_boxplot_interactive Create interactive boxplot
geom_bar_interactive Create interactive bars
dsvg SVG Graphics Driver
No Results!

Vignettes of ggiraph

No Results!

Last month downloads


Type Package
License GPL-3
Copyright See file COPYRIGHTS.
Encoding UTF-8
LinkingTo Rcpp, gdtools
VignetteBuilder knitr
RoxygenNote 6.1.1
Collate 'RcppExports.R' 'ipar.R' 'utils_ggplot2_performance.R' 'utils_ggplot2.R' 'utils.R' 'annotate_interactive.R' 'annotation_raster_interactive.R' 'dsvg.R' 'dsvg_view.R' 'element_interactive.R' 'fonts.R' 'geom_abline_interactive.R' 'geom_path_interactive.R' 'geom_polygon_interactive.R' 'geom_rect_interactive.R' 'geom_bar_interactive.R' 'geom_boxplot_interactive.R' 'geom_col_interactive.R' 'geom_contour_interactive.R' 'geom_crossbar_interactive.R' 'geom_density_2d_interactive.R' 'geom_density_interactive.R' 'geom_errorbar_interactive.R' 'geom_errorbarh_interactive.R' 'geom_freqpoly_interactive.R' 'geom_histogram_interactive.R' 'geom_hline_interactive.R' 'geom_jitter_interactive.R' 'geom_label_interactive.R' 'geom_linerange_interactive.R' 'geom_map_interactive.R' 'geom_point_interactive.R' 'geom_pointrange_interactive.R' 'geom_quantile_interactive.R' 'geom_raster_interactive.R' 'geom_ribbon_interactive.R' 'geom_segment_interactive.R' 'geom_sf_interactive.R' 'geom_smooth_interactive.R' 'geom_text_interactive.R' 'geom_tile_interactive.R' 'geom_vline_interactive.R' 'ggiraph.R' 'girafe.R' 'girafe_options.R' 'grob_interactive.R' 'guide_colourbar_interactive.R' 'guide_interactive.R' 'guide_legend_interactive.R' 'interactive_path_grob.R' 'interactive_points_grob.R' 'interactive_polygon_grob.R' 'interactive_polyline_grob.R' 'interactive_raster_grob.R' 'interactive_rect_grob.R' 'interactive_roundrect_grob.R' 'interactive_segments_grob.R' 'interactive_text_grob.R' 'layer_interactive.R' 'scale_alpha_interactive.R' 'scale_brewer_interactive.R' 'scale_colour_interactive.R' 'scale_gradient_interactive.R' 'scale_interactive.R' 'scale_linetype_interactive.R' 'scale_manual_interactive.R' 'scale_shape_interactive.R' 'scale_size_interactive.R' 'scale_viridis_interactive.R' 'svg.R' 'tracers.R'
NeedsCompilation yes
Packaged 2019-10-31 15:30:06 UTC; davidgohel
Repository CRAN
Date/Publication 2019-10-31 18:20:02 UTC

Include our badge in your README