I have created a 3D scatter plot using plotly()
on R shiny App. The code is as below :
output$threeDscatterPlot <- renderPlotly({
data <- dataInput()$data
plot.obj <<-list()
plot.obj$data <<- data
var7 <<- with(plot.obj$data,get(input$variable7))
var8 <<- with(plot.obj$data,get(input$variable8))
var9 <<- with(plot.obj$data,get(input$variable9))
var10 <<- with(plot.obj$data,get(input$variable10))
var10 <- as.factor(var10)
print(names(plot.obj$data))
p <- plot_ly(plot.obj$data, x = var7, y = var8 , z = var9 , type = "scatter3d", mode = "markers" ,
color = var10 , colors = "Paired" )
p %>% layout(legend = list(x = 1, y = 0.5 , bgcolor = "#E2E2E2"))
})
var7 , var8 , var9 are continous variable & var 10(categorical variable.
3D Plotly graph is coming very clearly but xaxis labels , yaxis labels and zaxis labels are comingas var 7 , var8 , var 9
My question is : How can we change the title of x , y , z axis to the actual variable name of var7/8/9 as in dataset/dataframe? I tried using xaxis .zaxis , yaxis but it does not seem to work How can we add the legend title just above the legend?
All done in R Shiny App
Thanks in Advance