'Having Problems Plotting a 3D Map in R

I am having problems plotting a 3D map in Rstudio.

Here is the code I used;

plot_ly(myLocalClean, x = ~date, y = ~median, z = ~sales, opacity=0.5) #3D

my result

No trace type specified: Based on info supplied, a 'scatter3d' trace seems appropriate. Read more about this trace type -> https://plotly.com/r/reference/#scatter3d No scatter3d mode specifed: Setting the mode to markers Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode

On the viewer tab, there is no result for the plot_ly. I get the error WebGL is not supported by your browser- visit https://get.webgl.org for more info

I tried to enable the webGL but I still get the same error.

Please I need your input.



Solution 1:[1]

If you run the following code, the errors are away:

library(plotly)
fig <- plot_ly(txhousing, x = ~date, y = ~median, z = ~sales)
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'date'),
                                   yaxis = list(title = 'median'),
                                   zaxis = list(title = 'sales')))

fig

Output:

enter image description here

The problem is that your data has a lot of missing values:

> sapply(txhousing, function(x) sum(is.na(x)))
     city      year     month     sales    volume    median  listings inventory      date 
        0         0         0       568       568       616      1424      1467         0 

That is way you get the warning message.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Quinten