Skip to content

Commit 39eeaaf

Browse files
authored
Merge pull request #316 from plotly/issue260
fix issue #260: surface
2 parents d0fb63c + 0eb86ae commit 39eeaaf

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
%-SURFACE DATA STRUCTURE- %
1010
image_data = get(obj.State.Plot(surfaceIndex).Handle);
1111
figure_data = get(obj.State.Figure.Handle);
12+
1213
%-AXIS DATA-%
1314
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
1415
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
@@ -35,7 +36,7 @@
3536

3637
%-surface x-%
3738
obj.data{surfaceIndex}.x = image_data.XData;
38-
39+
3940
%---------------------------------------------------------------------%
4041

4142
%-surface y-%
@@ -46,6 +47,28 @@
4647
%-surface z-%
4748
obj.data{surfaceIndex}.z = image_data.ZData;
4849

50+
%---------------------------------------------------------------------%
51+
52+
%- setting grid mesh by default -%
53+
% x-direction
54+
xmin = min(image_data.XData(:));
55+
xmax = max(image_data.XData(:));
56+
xsize = (xmax - xmin) / (size(image_data.XData, 2) - 1);
57+
obj.data{surfaceIndex}.contours.x.start = xmin;
58+
obj.data{surfaceIndex}.contours.x.end = xmax;
59+
obj.data{surfaceIndex}.contours.x.size = xsize;
60+
obj.data{surfaceIndex}.contours.x.show = true;
61+
obj.data{surfaceIndex}.contours.x.color = 'black';
62+
% y-direction
63+
ymin = min(image_data.YData(:));
64+
ymax = max(image_data.YData(:));
65+
ysize = (ymax - ymin) / (size(image_data.YData, 2));
66+
obj.data{surfaceIndex}.contours.y.start = ymin;
67+
obj.data{surfaceIndex}.contours.y.end = ymax;
68+
obj.data{surfaceIndex}.contours.y.size = ysize;
69+
obj.data{surfaceIndex}.contours.y.show = true;
70+
obj.data{surfaceIndex}.contours.y.color = 'black';
71+
4972

5073
else
5174

@@ -61,22 +84,18 @@
6184

6285
%-------------------------------------------------------------------------%
6386

64-
6587
%-image colorscale-%
6688

6789
cmap = figure_data.Colormap;
90+
len = length(cmap)-1;
6891

6992
for c = 1: length(cmap)
70-
x1=(c-1)/length(cmap);
71-
if x1 > 0.99
72-
x=round(x1);
73-
else
74-
x=x1;
75-
end
76-
obj.data{surfaceIndex}.colorscale{c} = { x , ['rgb(' num2str(255*cmap(c,1)) ',' num2str(255*cmap(c,2)) ',' num2str(255*cmap(c,3)) ',' ')' ] };
93+
col = 255 * cmap(c, :);
94+
obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] };
7795
end
7896

7997
obj.data{surfaceIndex}.surfacecolor = image_data.CData;
98+
8099
%-------------------------------------------------------------------------%
81100

82101
%-surface name-%

0 commit comments

Comments
 (0)