Skip to content

Commit 9dcd668

Browse files
fix issue #265
1 parent 7c90450 commit 9dcd668

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
if ~strcmpi(obj.PlotOptions.TreatAs, '_')
1010
if strcmpi(obj.PlotOptions.TreatAs, 'pie3')
1111
updatePie3(obj, dataIndex);
12+
elseif strcmpi(obj.PlotOptions.TreatAs, 'pcolor')
13+
updatePColor(obj, dataIndex);
1214
end
1315

1416
%-update plot based on plot call class-%
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
function obj = updatePColor(obj, patchIndex)
2+
3+
%-AXIS INDEX-%
4+
axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis);
5+
6+
%-PCOLOR DATA STRUCTURE- %
7+
pcolor_data = get(obj.State.Plot(patchIndex).Handle);
8+
figure_data = get(obj.State.Figure.Handle);
9+
10+
%-CHECK FOR MULTIPLE AXES-%
11+
[xsource, ysource] = findSourceAxis(obj,axIndex);
12+
13+
%-AXIS DATA-%
14+
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
15+
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
16+
17+
%-------------------------------------------------------------------------%
18+
19+
%-pcolor xaxis-%
20+
obj.data{patchIndex}.xaxis = ['x' num2str(xsource)];
21+
22+
%-------------------------------------------------------------------------%
23+
24+
%-pcolor yaxis-%
25+
obj.data{patchIndex}.yaxis = ['y' num2str(ysource)];
26+
27+
%-------------------------------------------------------------------------%
28+
29+
%-plot type: surface-%
30+
obj.data{patchIndex}.type = 'surface';
31+
32+
%-------------------------------------------------------------------------%
33+
34+
%-handle vertices-%
35+
xdata = []; ydata = []; zdata = []; cdata = [];
36+
37+
for n = 1:size(pcolor_data.XData, 2)-1
38+
for m = 1:size(pcolor_data.XData, 1)-1
39+
xdata = [xdata pcolor_data.XData(m:m+1, n:n+1) NaN(2,1)];
40+
ydata = [ydata pcolor_data.YData(m:m+1, n:n+1) NaN(2,1)];
41+
zdata = [zdata pcolor_data.ZData(m:m+1, n:n+1) NaN(2,1)];
42+
cdata = [cdata ones(2,3)*pcolor_data.CData(m, n)];
43+
end
44+
end
45+
46+
%-------------------------------------------------------------------------%
47+
48+
%-x-data-%
49+
obj.data{patchIndex}.x = xdata;
50+
51+
%-------------------------------------------------------------------------%
52+
53+
%-y-data-%
54+
obj.data{patchIndex}.y = ydata;
55+
56+
%-------------------------------------------------------------------------%
57+
58+
%-z-data-%
59+
obj.data{patchIndex}.z = zdata;
60+
61+
%-------------------------------------------------------------------------%
62+
63+
%-colorscale to map-%
64+
cmap = figure_data.Colormap;
65+
len = length(cmap)-1;
66+
67+
for c = 1: length(cmap)
68+
col = 255 * cmap(c, :);
69+
obj.data{patchIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] };
70+
end
71+
72+
obj.data{patchIndex}.surfacecolor = cdata;
73+
obj.data{patchIndex}.showscale = false;
74+
75+
%-------------------------------------------------------------------------%
76+
77+
%-aspectratio-%
78+
obj.layout.scene.aspectratio.x = 12;
79+
obj.layout.scene.aspectratio.y = 10;
80+
obj.layout.scene.aspectratio.z = 0.0001;
81+
82+
%-------------------------------------------------------------------------%
83+
84+
%-camera.eye-%
85+
obj.layout.scene.camera.eye.x = 0;
86+
obj.layout.scene.camera.eye.y = -0.5;
87+
obj.layout.scene.camera.eye.z = 14;
88+
89+
%-------------------------------------------------------------------------%
90+
91+
%-hide axis-x-%
92+
obj.layout.scene.xaxis.showticklabels = true;
93+
obj.layout.scene.xaxis.zeroline = false;
94+
obj.layout.scene.xaxis.showgrid = false;
95+
96+
%-------------------------------------------------------------------------%
97+
98+
%-hide axis-y-%
99+
obj.layout.scene.yaxis.zeroline = false;
100+
obj.layout.scene.yaxis.showgrid = false;
101+
obj.layout.scene.yaxis.showticklabels = true;
102+
103+
%-------------------------------------------------------------------------%
104+
105+
%-hide axis-z-%
106+
obj.layout.scene.zaxis.title = '';
107+
obj.layout.scene.zaxis.autotick = false;
108+
obj.layout.scene.zaxis.zeroline = false;
109+
obj.layout.scene.zaxis.showline = false;
110+
obj.layout.scene.zaxis.showticklabels = false;
111+
obj.layout.scene.zaxis.showgrid = false;
112+
113+
%-------------------------------------------------------------------------%
114+
115+
%-patch showlegend-%
116+
leg = get(pcolor_data.Annotation);
117+
legInfo = get(leg.LegendInformation);
118+
119+
switch legInfo.IconDisplayStyle
120+
case 'on'
121+
showleg = true;
122+
case 'off'
123+
showleg = false;
124+
end
125+
126+
obj.data{patchIndex}.showlegend = showleg;
127+
128+
%-------------------------------------------------------------------------%
129+
130+
end

0 commit comments

Comments
 (0)