我试图用R接口设置一个3D Scatterplot。 我的故事是:
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)
myaxis.list的定义如下:
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
)
我有两个问题: 我收到警告:
“警告消息:'布局'对象没有以下属性: 'zaxis'有效属性包括:'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','方向','方向','barmode', 'bargap','mapType'“。
所以我的第一个问题是:如何设定z轴美学?
提前感谢您的支持
答案 0 :(得分:1)
您需要将轴包裹在scene
。
layout(scene = list(xaxis = myaxis.list,
yaxis = myaxis.list,
zaxis = myaxis.list),
)
并通过range
指定轴的范围(即上限和下限)。
myaxis.list<- list(
autorange = FALSE,
range = c(-5, 5)
[...]
)
下图的完整代码
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))