使用Plotly fig2plotly()渲染MATLAB面片 [英] Rendering MATLAB patch faces with Plotly fig2plotly()

查看:116
本文介绍了使用Plotly fig2plotly()渲染MATLAB面片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:尝试在MATLAB中使用fig2plotly导出使用patch命令渲染的多边形时,最终输出缺少指定的面色.

Problem: When attempting to export a polygon rendered with the patch command in MATLAB with fig2plotly, the final output is lacking the specified face colours.

也许示范会有所帮助.采取以下顶点和面来定义一个立方体(从MATLAB文档中删除):

Perhaps a demonstration would help. Take the following vertices and faces to define a cube (lifted from the MATLAB documentation):

vert = [0 0 0;1 0 0;1 1 0;0 1 0;0 0 1;1 0 1;1 1 1;0 1 1];
fac = [1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];

并使用patch命令对其进行渲染,向面部添加一些颜色信息:

And render it with the patch command, adding some colour information to the faces:

patch('Vertices',vert,'Faces', fac, 'FaceVertexCData',hsv(8),'FaceColor','interp')

并以3D方式查看:

view(3)
axis vis3d

这提供了一个漂亮的立方体,表面上具有插值的颜色值.

This gives a nice cube with interpolated colour values on the surface.

现在,如果我们尝试使用fig2plotly命令将其导出到Plotly:

Now, if we attempt to export it to Plotly with the fig2plotly command:

fig2plotly(gcf)

它返回一个空的多维数据集( plotly链接):

It returns an empty cube (plotly link):

换句话说,已捕获线信息,但未捕获面部.即使我们尝试保留MATLAB样式,我们仍然会丢失人脸信息:

In other words, the line information has been captured, but not the faces. Even if we attempt to preserve the MATLAB styling, we still loose the face information:

fig2plotly(gcf, 'strip', false)

有什么建议吗?

推荐答案

改进了对补丁的支持.包装器的2.2.9( https://github.com/plotly/MATLAB-Online ).

Improved support for patches has been added to ver. 2.2.9 of the wrapper (https://github.com/plotly/MATLAB-Online).

您可以通过在plotlyfig.m文件中将TriangulatePatch默认设置为true来切换此改进的补丁处理. ( https://github.com/plotly/MATLAB -在线/blob/master/plotly/plotlyfig.m#L61 )

You can toggle this improved patch handling by setting the TriangulatePatch default to true within the plotlyfig.m file. (https://github.com/plotly/MATLAB-Online/blob/master/plotly/plotlyfig.m#L61)

尚不支持颜色渐变,但是补丁本身现在应该可以渲染.可以通过手动修改plotlyfig对象的属性或使用Web界面来进行颜色修改.

Colour gradients are not yet supported but the patches themselves should now render. Colour modifications can be made by manually modifying the attributes of the plotlyfig object or by using the web interface.

这篇关于使用Plotly fig2plotly()渲染MATLAB面片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆