# Overview of Plotly and R¶

Plotly is an R package for creating interactive web-based graphs via plotly's JavaScript graphing library, plotly.js. The plotly R libary contains a function ggplotly which will convert ggplot2 figures into graphs drawn with plotly.js which can be saved to an online plotly account or rendered locally.

You can install as a CRAN package:

In [ ]:

    install.packages('plotly')

Plotly has its own graphing call using plot_ly() but it also has ggplotly which allows you directly call ggplot() code! Sometimes this code needs some slight format change.

Once you've done that, you'll be able to call:

In [ ]:

    library(plotly)
    # pl <- # some ggplot2 code here
    print(ggplotly(pl))

Then you'll have an interactive plotly plot you can display in RStudio and Shiny!