Skip to content

Instantly share code, notes, and snippets.

@addiversitas
Last active October 18, 2020 16:12
Show Gist options
  • Save addiversitas/adebff6ad441f720cb954ac19fb0ba2b to your computer and use it in GitHub Desktop.
Save addiversitas/adebff6ad441f720cb954ac19fb0ba2b to your computer and use it in GitHub Desktop.
example of implied volatility surface plot
library(plotly)
xaxx <- list(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=TRUE,
backgroundcolor='rgb(230, 230,230)',
title = "Moneyness"
)
yaxx <- list(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=TRUE,
backgroundcolor='rgb(230, 230,230)',
title = "Time To Maturity"
)
zaxx <- list(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=TRUE,
backgroundcolor='rgb(230, 230,230)',
tickformat = "%",
title = "Implied Volatility"
)
fig <- plot_ly(x = colnames(ivGridCalls), y = rownames(ivGridCalls), z = ivGridCalls)
fig <- fig %>% add_surface()
fig <- fig %>% layout(scene = list(xaxis=xaxx, yaxis=yaxx, zaxis = zaxx))
fig <- fig %>% plotly::colorbar(title = "", x = 0.9, y = 0.75, tickformat = "%")
fig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment