quantitative_stock_analysis_tutorial icon indicating copy to clipboard operation
quantitative_stock_analysis_tutorial copied to clipboard

plot_ly gives error

Open mattneib opened this issue 7 years ago • 0 comments

plot_ly portion of program:

Quitting from lines 470-509 (StockSP.Rmd) Error in lengths(x$annotations) : 'x' must be a list Calls: <Anonymous> ... plotly_build.plotly -> Map -> mapply -> <Anonymous> -> %||% -> lengths

Code:

library(plotly) plot_ly(data = sp_500, type = "scatter", mode = "markers", x = ~ sd.log.returns, y = ~ mean.log.returns, color = ~ n.trade.days, colors = "Blues", size = ~ n.trade.days, text = ~ str_c("", security, "
", "Ticker: ", ticker.symbol, "
", "Sector: ", gics.sector, "
", "Sub Sector: ", gics.sub.industry, "
", "No. of Trading Days: ", n.trade.days), marker = list(opacity = 0.8, symbol = 'circle', sizemode = 'diameter', sizeref = 4.0, line = list(width = 2, color = '#FFFFFF')) ) %>% layout(title = 'S&P500 Analysis: Stock Risk vs Reward', xaxis = list(title = 'Risk/Variability (StDev Log Returns)', gridcolor = 'rgb(255, 255, 255)', zerolinewidth = 1, ticklen = 5, gridwidth = 2), yaxis = list(title = 'Reward/Growth (Mean Log Returns)', gridcolor = 'rgb(255, 255, 255)', zerolinewidth = 1, ticklen = 5, gridwith = 2), margin = list(l = 100, t = 100, b = 100), font = list(color = '#FFFFFF'), paper_bgcolor = 'rgb(0, 0, 0)', plot_bgcolor = 'rgb(0, 0, 0)')

mattneib avatar Jul 22 '18 16:07 mattneib