Skip to content

Commit 9ae608f

Browse files
fix issue #266
1 parent aa634e8 commit 9ae608f

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

plotly/plotlyfig_aux/core/updateData.m

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
updateRectangle(obj,dataIndex);
3333
case 'surface'
3434
updateSurfaceplot(obj,dataIndex);
35+
case 'functionsurface'
36+
updateFunctionSurface(obj,dataIndex);
3537

3638
%-GROUP PLOT OBJECTS-%
3739
case 'area'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
function obj = updateFunctionSurface(obj, surfaceIndex)
2+
3+
%-AXIS INDEX-%
4+
axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis);
5+
6+
%-CHECK FOR MULTIPLE AXES-%
7+
[xsource, ysource] = findSourceAxis(obj,axIndex);
8+
9+
%-SURFACE DATA STRUCTURE- %
10+
image_data = get(obj.State.Plot(surfaceIndex).Handle);
11+
figure_data = get(obj.State.Figure.Handle);
12+
13+
%-AXIS DATA-%
14+
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
15+
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
16+
17+
%-------------------------------------------------------------------------%
18+
19+
%-surface xaxis-%
20+
obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)];
21+
22+
%-------------------------------------------------------------------------%
23+
24+
%-surface yaxis-%
25+
obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)];
26+
27+
%-------------------------------------------------------------------------%
28+
29+
%-surface type-%
30+
obj.data{surfaceIndex}.type = 'surface';
31+
32+
%---------------------------------------------------------------------%
33+
34+
%-surface x-%
35+
mden = image_data.MeshDensity;
36+
x = reshape(image_data.XData(1:mden*mden), [mden, mden]);
37+
obj.data{surfaceIndex}.x = x;
38+
39+
%---------------------------------------------------------------------%
40+
41+
%-surface y-%
42+
y = reshape(image_data.YData(1:mden*mden), [mden, mden]);
43+
obj.data{surfaceIndex}.y = y;
44+
45+
%---------------------------------------------------------------------%
46+
47+
%-surface z-%
48+
z = reshape(image_data.ZData(1:mden*mden), [mden, mden]);
49+
obj.data{surfaceIndex}.z = z;
50+
51+
%---------------------------------------------------------------------%
52+
53+
%- setting grid mesh by default -%
54+
% x-direction
55+
xmin = min(x(:));
56+
xmax = max(x(:));
57+
xsize = (xmax - xmin) / mden;
58+
obj.data{surfaceIndex}.contours.x.start = xmin;
59+
obj.data{surfaceIndex}.contours.x.end = xmax;
60+
obj.data{surfaceIndex}.contours.x.size = xsize;
61+
obj.data{surfaceIndex}.contours.x.show = true;
62+
obj.data{surfaceIndex}.contours.x.color = 'black';
63+
% y-direction
64+
ymin = min(y(:));
65+
ymax = max(y(:));
66+
ysize = (ymax - ymin) / mden;
67+
obj.data{surfaceIndex}.contours.y.start = ymin;
68+
obj.data{surfaceIndex}.contours.y.end = ymax;
69+
obj.data{surfaceIndex}.contours.y.size = ysize;
70+
obj.data{surfaceIndex}.contours.y.show = true;
71+
obj.data{surfaceIndex}.contours.y.color = 'black';
72+
73+
%-------------------------------------------------------------------------%
74+
75+
%-image colorscale-%
76+
77+
cmap = figure_data.Colormap;
78+
len = length(cmap)-1;
79+
80+
for c = 1: length(cmap)
81+
col = 255 * cmap(c, :);
82+
obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] };
83+
end
84+
85+
obj.data{surfaceIndex}.surfacecolor = z;
86+
87+
%-------------------------------------------------------------------------%
88+
89+
%-surface name-%
90+
obj.data{surfaceIndex}.name = image_data.DisplayName;
91+
92+
%-------------------------------------------------------------------------%
93+
94+
%-surface showscale-%
95+
obj.data{surfaceIndex}.showscale = false;
96+
97+
%-------------------------------------------------------------------------%
98+
99+
%-surface visible-%
100+
obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on');
101+
102+
%-------------------------------------------------------------------------%
103+
104+
leg = get(image_data.Annotation);
105+
legInfo = get(leg.LegendInformation);
106+
107+
switch legInfo.IconDisplayStyle
108+
case 'on'
109+
showleg = true;
110+
case 'off'
111+
showleg = false;
112+
end
113+
114+
obj.data{surfaceIndex}.showlegend = showleg;
115+
116+
%-------------------------------------------------------------------------%
117+
118+
end

0 commit comments

Comments
 (0)