From aa634e8debe57766ca22c5f294167c0b3975f554 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Sun, 8 Aug 2021 19:26:23 -0400 Subject: [PATCH 1/4] fix issue #281 --- .../handlegraphics/updateImage.m | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index f1b37783..6dd7e279 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -64,8 +64,11 @@ %-------------------------------------------------------------------------% %-image x-% +x = image_data.XData; +cdata = image_data.CData; + if (size(image_data.XData,2) == 2) - obj.data{imageIndex}.x = image_data.XData(1):image_data.XData(2); + obj.data{imageIndex}.x = linspace(x(1), x(2), size(cdata,2)); else obj.data{imageIndex}.x = image_data.XData; end @@ -73,10 +76,12 @@ %-------------------------------------------------------------------------% %-image y-% +y = image_data.YData; + if (size(image_data.YData,2) == 2) - obj.data{imageIndex}.y = image_data.YData(1):image_data.YData(2); + obj.data{imageIndex}.y = linspace(y(1), y(2), size(cdata,1)); else - obj.data{imageIndex}.y = image_data.YData; + obj.data{imageIndex}.y = y; end %-------------------------------------------------------------------------% @@ -84,9 +89,9 @@ %-image z-% if(size(image_data.CData,3) > 1) % TODO: ALLOW FOR TRUE COLOUR SPECS. - obj.data{imageIndex}.z = image_data.CData(:,:,1); + obj.data{imageIndex}.z = cdata(:,:,1); else - obj.data{imageIndex}.z = image_data.CData; + obj.data{imageIndex}.z = cdata; end %-------------------------------------------------------------------------% @@ -121,8 +126,11 @@ %-------------------------------------------------------------------------% %-image zmax-% -axis_data.CLim(2); -% obj.data{imageIndex}.zmax = 255; % comment this as optional +if ~strcmpi(image_data.CDataMapping, 'direct') + obj.data{imageIndex}.zmax = axis_data.CLim(2); +else + obj.data{imageIndex}.zmax = 255; +end %-------------------------------------------------------------------------% From 9ae608f20c435fc2c9ab2eecafcabbbb0f012759 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Sun, 8 Aug 2021 21:00:45 -0400 Subject: [PATCH 2/4] fix issue #266 --- plotly/plotlyfig_aux/core/updateData.m | 2 + .../handlegraphics/updateFunctionSurface.m | 118 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 1fb8b581..e828c8ad 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -32,6 +32,8 @@ updateRectangle(obj,dataIndex); case 'surface' updateSurfaceplot(obj,dataIndex); + case 'functionsurface' + updateFunctionSurface(obj,dataIndex); %-GROUP PLOT OBJECTS-% case 'area' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m new file mode 100644 index 00000000..c5bc92ed --- /dev/null +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -0,0 +1,118 @@ +function obj = updateFunctionSurface(obj, surfaceIndex) + +%-AXIS INDEX-% +axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + +%-CHECK FOR MULTIPLE AXES-% +[xsource, ysource] = findSourceAxis(obj,axIndex); + +%-SURFACE DATA STRUCTURE- % +image_data = get(obj.State.Plot(surfaceIndex).Handle); +figure_data = get(obj.State.Figure.Handle); + +%-AXIS DATA-% +eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); +eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); + +%-------------------------------------------------------------------------% + +%-surface xaxis-% +obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; + +%-------------------------------------------------------------------------% + +%-surface yaxis-% +obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + +%-------------------------------------------------------------------------% + +%-surface type-% +obj.data{surfaceIndex}.type = 'surface'; + +%---------------------------------------------------------------------% + +%-surface x-% +mden = image_data.MeshDensity; +x = reshape(image_data.XData(1:mden*mden), [mden, mden]); +obj.data{surfaceIndex}.x = x; + +%---------------------------------------------------------------------% + +%-surface y-% +y = reshape(image_data.YData(1:mden*mden), [mden, mden]); +obj.data{surfaceIndex}.y = y; + +%---------------------------------------------------------------------% + +%-surface z-% +z = reshape(image_data.ZData(1:mden*mden), [mden, mden]); +obj.data{surfaceIndex}.z = z; + +%---------------------------------------------------------------------% + +%- setting grid mesh by default -% +% x-direction +xmin = min(x(:)); +xmax = max(x(:)); +xsize = (xmax - xmin) / mden; +obj.data{surfaceIndex}.contours.x.start = xmin; +obj.data{surfaceIndex}.contours.x.end = xmax; +obj.data{surfaceIndex}.contours.x.size = xsize; +obj.data{surfaceIndex}.contours.x.show = true; +obj.data{surfaceIndex}.contours.x.color = 'black'; +% y-direction +ymin = min(y(:)); +ymax = max(y(:)); +ysize = (ymax - ymin) / mden; +obj.data{surfaceIndex}.contours.y.start = ymin; +obj.data{surfaceIndex}.contours.y.end = ymax; +obj.data{surfaceIndex}.contours.y.size = ysize; +obj.data{surfaceIndex}.contours.y.show = true; +obj.data{surfaceIndex}.contours.y.color = 'black'; + +%-------------------------------------------------------------------------% + +%-image colorscale-% + +cmap = figure_data.Colormap; +len = length(cmap)-1; + +for c = 1: length(cmap) + col = 255 * cmap(c, :); + obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; +end + +obj.data{surfaceIndex}.surfacecolor = z; + +%-------------------------------------------------------------------------% + +%-surface name-% +obj.data{surfaceIndex}.name = image_data.DisplayName; + +%-------------------------------------------------------------------------% + +%-surface showscale-% +obj.data{surfaceIndex}.showscale = false; + +%-------------------------------------------------------------------------% + +%-surface visible-% +obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); + +%-------------------------------------------------------------------------% + +leg = get(image_data.Annotation); +legInfo = get(leg.LegendInformation); + +switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; +end + +obj.data{surfaceIndex}.showlegend = showleg; + +%-------------------------------------------------------------------------% + +end From f7d8f2450073c64ebb2b1a12c9fc137205c91ddc Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Mon, 9 Aug 2021 18:15:12 -0400 Subject: [PATCH 3/4] fix issue #306 --- plotly/plotlyfig_aux/handlegraphics/updateLineseries.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 40f70dd3..e20bac47 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -132,7 +132,10 @@ function updateLineseries(obj,plotIndex) %-------------------------------------------------------------------------% if isfield(plot_data,'ZData') - if any(plot_data.ZData) + + numbset = unique(plot_data.ZData); + + if any(plot_data.ZData) && length(numbset)>1 %-scatter z-% obj.data{plotIndex}.z = plot_data.ZData; From de5c9294164793ebe0d3af46fc5644da9b65abf3 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Mon, 9 Aug 2021 18:53:59 -0400 Subject: [PATCH 4/4] fix issue #283 --- plotly/plotlyfig_aux/handlegraphics/updateImage.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index 6dd7e279..0efa919b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -87,9 +87,11 @@ %-------------------------------------------------------------------------% %-image z-% -if(size(image_data.CData,3) > 1) - % TODO: ALLOW FOR TRUE COLOUR SPECS. - obj.data{imageIndex}.z = cdata(:,:,1); +isrgbimg = (size(image_data.CData,3) > 1); + +if isrgbimg + [IND,colormap] = rgb2ind(cdata, 256); + obj.data{imageIndex}.z = IND; else obj.data{imageIndex}.z = cdata; end @@ -137,7 +139,11 @@ %-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% %-image colorscale-% -colormap = figure_data.Colormap; + +if ~isrgbimg + colormap = figure_data.Colormap; +end + len = length(colormap) - 1; for c = 1:size(colormap, 1)