13

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.

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];

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

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

And view it in 3D:

view(3)
axis vis3d

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

nice cube

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

fig2plotly(gcf)

It returns an empty cube (plotly link):

empty cube

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)

Any suggestions?

Wolfie
  • 27,562
  • 7
  • 28
  • 55
Ivan A
  • 303
  • 1
  • 9
  • 4
    Welcome to Stack Overflow, and thanks for the exceptionally well-fomed question:) I just want to note that I'm always amazed by the uselessness of the so-called full documentation of plotly. Very shiny, utterly useless. (Maybe the problem's with me.) From the little information I could find, `fig2plotly` should do its job mostly on its own. So maybe you should file a bugreport if you don't get an answer from someone else here. – Andras Deak -- Слава Україні Jan 11 '16 at 17:03
  • @AndrasDeak thanks! I've been reading StackOverflow for a while, so just trying to stick to the community standards. Indeed, I can't see any documentation for MATLAB surfaces/patches in plotly, so I may have to take directly with them. In the meantime, if anyone knows the answer I would love to hear it! – Ivan A Jan 12 '16 at 13:28

1 Answers1

3

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

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)

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.

Bronsolo
  • 46
  • 2