Making images using Plotly

Here’s a blurb from the website:

“Plotly’s R graphing library makes interactive, publication-quality graphs online. Examples of how to make line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts and bubble charts.”

And here’s a Plotly graphic! Check out the interactive features.

library(plotly)
set.seed(02143)
d <- diamonds[sample(nrow(diamonds), 1000), ]

plot_ly(d, x = ~carat, y = ~price, color = ~carat,
        size = ~carat, text = ~paste("Clarity: ", clarity))

ggplot2 Integration: ggplotly

Also, you don’t have to learn any new code to use plotly. This graph is made with ggplot syntax incorporated into a ggplotly wrapper:

p <- ggplot(data = d, aes(x = carat, y = price)) +
  geom_point(aes(text = paste("Clarity:", clarity))) +
  geom_smooth(aes(colour = cut, fill = cut)) + facet_wrap(~ cut)

ggplotly(p)