Choropleth Maps: Setup

Choropleth maps illustrate data across geographic areas by shading regions with different colors. Choropleth maps are easy to make with Plotly though they require more setup compared to other Plotly graphics.

library(plotly)
## Warning: package 'plotly' was built under R version 3.3.3
## Warning: package 'ggplot2' was built under R version 3.3.3
plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter")

Basic Scatterplot

plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", color = ~factor(cyl))

Continuous Color

plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", color = ~disp)

Scatterplot Sizing

plot_ly(mtcars, x = ~wt, y = ~mpg, type = "scatter", 
        color = ~factor(cyl), size = ~hp)

3D Scatterplot

set.seed(2016-07-21)
temp <- rnorm(100, mean = 30, sd = 5)
pressue <- rnorm(100)
dtime <- 1:100
plot_ly(x = ~temp, y = ~pressue, z = ~dtime,
        type = "scatter3d", color = ~temp)