Show Sidebar Hide Sidebar

Getting Started with Plotly in R

How to get started making charts with Plotly's R graphing library.

Getting Started with Plotly for R

plotly is an R package for creating interactive web-based graphs via the open source JavaScript graphing library plotly.js.

As of version 2.0 (November 17, 2015), graphs created with the plotly R package are rendered locally through the htmlwidgets framework.

Installation

Download from CRAN

Use the install.package() function to install the plotly R package from [CRAN](https://cran.r-project.org/!

install.packages("plotly")

Download from GitHub

Alternatively, you can install the latest development version of plotly from GitHub via the devtools R package:

devtools::install_github("ropensci/plotly")

Note For RStudio Users

RStudio users should ensure that they are using the latest RStudio release in order to ensure compatibility with the htmlwidgets R package.

Rendering Charts

By default, the plotly R package runs locally in your web browser or in the RStudio viewer.

library(plotly)
p <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
p

Simply printing the plot object will render the chart locally in your web browser or in the RStudio viewer.

Graphs created with the plotly R package are interactive!

Click on legend entries to hide/show traces, click-and-drag on the chart to zoom, double-click to autoscale, shift-and-drag to pan.

Next Steps

Once you have installed the plotly R package, learn more about the fundamentals of making charts and start making basic charts.