简体   繁体   English

R z轴和同构图上的3D散点图

[英]plotly 3D scatterplot in R z axis and isomorphis

I am trying to set out a 3D Scatterplot with the R interface to plotly. 我正在尝试通过R接口设置3D散点图。 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的定义如前:

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: 我有两个问题:1.我收到警告:

"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'". “警告消息:'布局'对象不具有以下属性:'zaxis'有效属性包括:'font','title','titlefont','autosize','width','height','margin', 'paper_bgcolor','plot_bgcolor','separators','hidesources','smith','showlegend','dragmode','hovermode','xaxis','yaxis','scene','geo','legend ”,“注释”,“形状”,“图像”,“ updatemenus”,“三元”,“ mapbox”,“ radialaxis”,“ angularaxis”,“ direction”,“ orientation”,“ barmode”,“ bargap”, 'mapType'”。

So my first question is: how to set out the z axis esthetics? 所以我的第一个问题是:如何设定z轴美学?

  1. I would like to have an isomorphic graph: same spacing between ticks, same scale on the x,y,z axis. 我想要一个同构图:刻度线之间的间距相同,x,y,z轴上的比例尺相同。 How can I get this? 我怎么能得到这个?

Thanks in advance for your support 预先感谢您的支持

You would need to wrap your axes in a scene . 您需要将轴包装在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 . 并通过指定范围的轴(即上界和下界) 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))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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