Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R:在R中打印三维对象(虹膜数据)_R_Plotly_Data Visualization_Data Manipulation - Fatal编程技术网

R:在R中打印三维对象(虹膜数据)

R:在R中打印三维对象(虹膜数据),r,plotly,data-visualization,data-manipulation,R,Plotly,Data Visualization,Data Manipulation,我正在使用R编程语言。我在这里尝试遵循本教程: 对于著名的Iris数据集,我尝试绘制随机森林算法的3D决策面(使用tsne维度): 但我得到了以下错误: 2: In RColorBrewer::brewer.pal(N, "Set2") : minimal value for n is 3, returning requested palette with 3 different levels 3: 'mesh3d' objects don't have these a

我正在使用R编程语言。我在这里尝试遵循本教程:

对于著名的Iris数据集,我尝试绘制随机森林算法的3D决策面(使用tsne维度):

但我得到了以下错误:

2: In RColorBrewer::brewer.pal(N, "Set2") :
  minimal value for n is 3, returning requested palette with 3 different levels

3: 'mesh3d' objects don't have these attributes: 'mode', 'marker'
Valid attributes include:
'type', 'visible', 'legendgroup', 'name', 'uid', 'ids', 'customdata', 'meta', 'hoverlabel', 'stream', 'uirevision', 'x', 'y', 'z', 'i', 'j', 'k', 'text', 'hovertext', 'hovertemplate', 'delaunayaxis', 'alphahull', 'intensity', 'intensitymode', 'color', 'vertexcolor', 'facecolor', 'cauto', 'cmin', 'cmax', 'cmid', 'colorscale', 'autocolorscale', 'reversescale', 'showscale', 'colorbar', 'coloraxis', 'opacity', 'flatshading', 'contour', 'lightposition', 'lighting', 'hoverinfo', 'showlegend', 'xcalendar', 'ycalendar', 'zcalendar', 'scene', 'idssrc', 'customdatasrc', 'metasrc', 'xsrc', 'ysrc', 'zsrc', 'isrc', 'jsrc', 'ksrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'intensitysrc', 'vertexcolorsrc', 'facecolorsrc', 'hoverinfosrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
 
生成了三维绘图,但三维平面已完全消失

有人能告诉我我做错了什么吗

我试图使鼠标移动到每个点上时,该点将显示$Sepal.Length、$Sepal.Width、$Petal.Length、$Petal.Width、$Species的值


谢谢

当您调用
add_trace()
时,
z
分配不正确。标签不会打印;您需要绘制您确定的概率,
z=df_m2$pred

有多种方法可以解决网格打印问题,但最简单的方法是使用
add_mesh
而不是
add_trace

plot_ly(x=as.vector(axis_1),
        y=as.vector(axis_2), 
        z=axis_3, 
        type="scatter3d",
        mode="markers", 
        name = "Obs", 
        marker = list(size = 3)) %>% 
   add_mesh(x=as.vector(axis_1), 
            y=as.vector(axis_2), 
            z=df_m2$pred, 
            type = "mesh3d", 
            name = "Preds")

非常感谢你!我花了好几个小时想弄明白!太完美了!只有两个问题:当你将鼠标移动到每个点上时,你如何制作标签(花瓣宽度、花瓣长度等)?是否可以将标签“a”标记为蓝色,“b”标记为红色?非常感谢你!如果你有时间可以看一下这个吗?谢谢
2: In RColorBrewer::brewer.pal(N, "Set2") :
  minimal value for n is 3, returning requested palette with 3 different levels

3: 'mesh3d' objects don't have these attributes: 'mode', 'marker'
Valid attributes include:
'type', 'visible', 'legendgroup', 'name', 'uid', 'ids', 'customdata', 'meta', 'hoverlabel', 'stream', 'uirevision', 'x', 'y', 'z', 'i', 'j', 'k', 'text', 'hovertext', 'hovertemplate', 'delaunayaxis', 'alphahull', 'intensity', 'intensitymode', 'color', 'vertexcolor', 'facecolor', 'cauto', 'cmin', 'cmax', 'cmid', 'colorscale', 'autocolorscale', 'reversescale', 'showscale', 'colorbar', 'coloraxis', 'opacity', 'flatshading', 'contour', 'lightposition', 'lighting', 'hoverinfo', 'showlegend', 'xcalendar', 'ycalendar', 'zcalendar', 'scene', 'idssrc', 'customdatasrc', 'metasrc', 'xsrc', 'ysrc', 'zsrc', 'isrc', 'jsrc', 'ksrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'intensitysrc', 'vertexcolorsrc', 'facecolorsrc', 'hoverinfosrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
 
plot_ly(x=as.vector(axis_1),
        y=as.vector(axis_2), 
        z=axis_3, 
        type="scatter3d",
        mode="markers", 
        name = "Obs", 
        marker = list(size = 3)) %>% 
   add_mesh(x=as.vector(axis_1), 
            y=as.vector(axis_2), 
            z=df_m2$pred, 
            type = "mesh3d", 
            name = "Preds")