library(plotly)
## Loading required package: ggplot2
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
quakes = read.csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')
p <- quakes %>%
plot_ly(
type = 'densitymapbox',
lat = ~Latitude,
lon = ~Longitude,
coloraxis = 'coloraxis',
radius = 10) %>%
layout(
mapbox = list(
style="stamen-terrain",
center= list(lon=180)), coloraxis = list(colorscale = "Viridis"))
Interactive Map Plot
p
# volcano is a numeric matrix that ships with R
g <- plot_ly(z = ~volcano) %>% add_surface(
contours = list(
z = list(
show=TRUE,
usecolormap=TRUE,
highlightcolor="#ff0000",
project=list(z=TRUE)
)
)
) %>%
layout(
scene = list(
camera=list(
eye = list(x=1.87, y=0.88, z=-0.64)
)
)
)
Interactive Surface Plot
g