From 3e154d91b750b9a0f9d909a9da45de35c64524a0 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Thu, 5 Aug 2021 11:50:03 -0400 Subject: [PATCH] fix issue 280 --- .../handlegraphics/updateImage.m | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index 453c83c8..073a7590 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -92,7 +92,9 @@ %-------------------------------------------------------------------------% %-image name-% -obj.data{imageIndex}.name = image_data.DisplayName; +try + obj.data{imageIndex}.name = image_data.DisplayName; +end %-------------------------------------------------------------------------% @@ -117,7 +119,8 @@ %-------------------------------------------------------------------------% %-image zmax-% -obj.data{imageIndex}.zmax = axis_data.CLim(2); +% axis_data.CLim(2); % comment this as optional +obj.data{imageIndex}.zmax = 255; %-------------------------------------------------------------------------% @@ -125,27 +128,30 @@ %-image colorscale-% colormap = figure_data.Colormap; +len = length(colormap) - 1; -for c = 1:length(colormap) +for c = 1:size(colormap, 1) col = 255*(colormap(c,:)); - obj.data{imageIndex}.colorscale{c} = {(c-1)/length(colormap), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; + obj.data{imageIndex}.colorscale{c} = {(c-1)/len, ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; end %-------------------------------------------------------------------------% %-image showlegend-% -leg = get(image_data.Annotation); -legInfo = get(leg.LegendInformation); - -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; +try + leg = get(image_data.Annotation); + legInfo = get(leg.LegendInformation); + + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + + obj.data{imageIndex}.showlegend = showleg; end -obj.data{imageIndex}.showlegend = showleg; - %-------------------------------------------------------------------------% end