简体   繁体   中英

plotly 3D scatterplot in R z axis and isomorphis

I am trying to set out a 3D Scatterplot with the R interface to plotly. My plotly call is:

p.sagittale<-plot_ly(data=filter(temp,tipo=='Caucasici'), x = ~coordX.Sagg , y = ~ coordY.Sagg, z = ~coordZ.Sagg,text = ~punti) %>% 
add_markers(color=~cluster) %>% 
layout(title = paste('Caucasici','Dente',i,'Sagittale'), xaxis = myaxis.list, yaxis = myaxis.list, zaxis=myaxis.list)

where the myaxis.list is defined as before:

myaxis.list<- list(
    zeroline = TRUE,
    showline = TRUE,
    mirror = "ticks",
    gridcolor = toRGB("gray50"),
    gridwidth = 2,
    zerolinecolor = toRGB("blue"),
    zerolinewidth = 4,
    linecolor = toRGB("black"),
    linewidth = 6,
    autotick = FALSE,
    ticks = "outside",
    tick0 = 0,
    dtick = 0.25
  )

I have two issues: 1. I receive a warning:

"Warning message: 'layout' objects don't have these attributes: 'zaxis' Valid attributes include: 'font', 'title', 'titlefont', 'autosize', 'width', 'height', 'margin', 'paper_bgcolor', 'plot_bgcolor', 'separators', 'hidesources', 'smith', 'showlegend', 'dragmode', 'hovermode', 'xaxis', 'yaxis', 'scene', 'geo', 'legend', 'annotations', 'shapes', 'images', 'updatemenus', 'ternary', 'mapbox', 'radialaxis', 'angularaxis', 'direction', 'orientation', 'barmode', 'bargap', 'mapType'".

So my first question is: how to set out the z axis esthetics?

  1. I would like to have an isomorphic graph: same spacing between ticks, same scale on the x,y,z axis. How can I get this?

Thanks in advance for your support

You would need to wrap your axes in a scene .

layout(scene = list(xaxis = myaxis.list,
                    yaxis = myaxis.list,
                    zaxis = myaxis.list),
       )

and specify the range (ie upper and lower bound) of your axes via range .

myaxis.list<- list( 
  autorange = FALSE,
  range = c(-5, 5)
  [...]
) 

The complete code for the graph below

myaxis.list<- list( 
  zeroline = TRUE, 
  showline = TRUE, 
  mirror = "ticks", 
  gridcolor = toRGB("gray50"), 
  gridwidth = 2, 
  zerolinecolor = toRGB("blue"), 
  zerolinewidth = 4, 
  linecolor = toRGB("black"), 
  linewidth = 6, 
  autotick = FALSE, 
  ticks = "outside", 
  tick0 = 0, 
  dtick = 0.25,
  autorange = FALSE,
  range = c(-5, 5)
) 
p.sagittale<-plot_ly(data=filter(temp,tipo=='Caucasici'), x = ~coordX.Sagg , y = ~ coordY.Sagg, z = ~coordZ.Sagg,text = ~punti) %>%
add_markers(color=~cluster) %>%
layout(title = paste('Caucasici','Dente',"i",'Sagittale'), scene=list(xaxis = myaxis.list, yaxis = myaxis.list, zaxis=myaxis.list))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM