R Markdown & Plotly

David Galbraith

12 November 2016

Plotly Toroidal Surface Plot

The following representation of a 3-d toroidal surface map was generated using the Plotly library in R:

Source for Plotly Toroidal Surface Plot

The R source code used to generate the 3-d toroidal surface map using the Plotly library:

library(plotly)

t <- seq(0, 2 * pi, length.out = 50); 
u <- seq(0, 2 * pi, length.out = 50); 
R <- 6; 
r <- 3; 

xm<-outer(t, u, function(t, u) cos(t) * (R + r * cos(u)))
ym<-outer(t, u, function(t, u) sin(t) * (R + r * cos(u)))
zm<-outer(t, u, function(t, u) r * sin(u))

plot_ly() %>% add_surface(x = xm, y = ym, z = zm) %>%
              layout(title = '3-D Toroidal Surface Plot',
                     hoverinfo = 'x + y + z')