Skip to content

Commit 3e154d9

Browse files
fix issue 280
1 parent edcf9b0 commit 3e154d9

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

plotly/plotlyfig_aux/handlegraphics/updateImage.m

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@
9292
%-------------------------------------------------------------------------%
9393

9494
%-image name-%
95-
obj.data{imageIndex}.name = image_data.DisplayName;
95+
try
96+
obj.data{imageIndex}.name = image_data.DisplayName;
97+
end
9698

9799
%-------------------------------------------------------------------------%
98100

@@ -117,35 +119,39 @@
117119
%-------------------------------------------------------------------------%
118120

119121
%-image zmax-%
120-
obj.data{imageIndex}.zmax = axis_data.CLim(2);
122+
% axis_data.CLim(2); % comment this as optional
123+
obj.data{imageIndex}.zmax = 255;
121124

122125
%-------------------------------------------------------------------------%
123126

124127
%-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-%
125128

126129
%-image colorscale-%
127130
colormap = figure_data.Colormap;
131+
len = length(colormap) - 1;
128132

129-
for c = 1:length(colormap)
133+
for c = 1:size(colormap, 1)
130134
col = 255*(colormap(c,:));
131-
obj.data{imageIndex}.colorscale{c} = {(c-1)/length(colormap), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']};
135+
obj.data{imageIndex}.colorscale{c} = {(c-1)/len, ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']};
132136
end
133137

134138
%-------------------------------------------------------------------------%
135139

136140
%-image showlegend-%
137-
leg = get(image_data.Annotation);
138-
legInfo = get(leg.LegendInformation);
139-
140-
switch legInfo.IconDisplayStyle
141-
case 'on'
142-
showleg = true;
143-
case 'off'
144-
showleg = false;
141+
try
142+
leg = get(image_data.Annotation);
143+
legInfo = get(leg.LegendInformation);
144+
145+
switch legInfo.IconDisplayStyle
146+
case 'on'
147+
showleg = true;
148+
case 'off'
149+
showleg = false;
150+
end
151+
152+
obj.data{imageIndex}.showlegend = showleg;
145153
end
146154

147-
obj.data{imageIndex}.showlegend = showleg;
148-
149155
%-------------------------------------------------------------------------%
150156

151157
end

0 commit comments

Comments
 (0)