From 0eb86ae886c3434158b576ea1be20d163bebaea6 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Thu, 5 Aug 2021 18:58:16 -0400 Subject: [PATCH 1/3] fix issue #260: surface --- .../handlegraphics/updateSurfaceplot.m | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index 02543c7e..de878305 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -9,6 +9,7 @@ %-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) ';']); @@ -35,7 +36,7 @@ %-surface x-% obj.data{surfaceIndex}.x = image_data.XData; - + %---------------------------------------------------------------------% %-surface y-% @@ -46,6 +47,28 @@ %-surface z-% obj.data{surfaceIndex}.z = image_data.ZData; + %---------------------------------------------------------------------% + + %- setting grid mesh by default -% + % x-direction + xmin = min(image_data.XData(:)); + xmax = max(image_data.XData(:)); + xsize = (xmax - xmin) / (size(image_data.XData, 2) - 1); + 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(image_data.YData(:)); + ymax = max(image_data.YData(:)); + ysize = (ymax - ymin) / (size(image_data.YData, 2)); + 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'; + else @@ -61,22 +84,18 @@ %-------------------------------------------------------------------------% - %-image colorscale-% cmap = figure_data.Colormap; +len = length(cmap)-1; for c = 1: length(cmap) - x1=(c-1)/length(cmap); - if x1 > 0.99 - x=round(x1); - else - x=x1; - end - obj.data{surfaceIndex}.colorscale{c} = { x , ['rgb(' num2str(255*cmap(c,1)) ',' num2str(255*cmap(c,2)) ',' num2str(255*cmap(c,3)) ',' ')' ] }; + 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 = image_data.CData; + %-------------------------------------------------------------------------% %-surface name-% From 9bf436ee1bf6bce40e799950720f47e5ce1e8afb Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Thu, 5 Aug 2021 20:49:00 -0400 Subject: [PATCH 2/3] fix issue #302 --- plotly/plotlyfig_aux/handlegraphics/updateLineseries.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 51986b60..cdd0d324 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -74,8 +74,8 @@ function updateLineseries(obj,plotIndex) ispolar = true; end -%-if polar ezplot or not-% -if abs(x(1)-x(end))<1e-5 && abs(y(1)-y(end))<1e-5 +%-if ezpolar or not-% +if length(obj.State.Axis(plotIndex).Handle.Children) == 2 ispolar = true; end From 8217b48eef4abdf2cbfb681beef3af172cb9396a Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Fri, 6 Aug 2021 21:25:21 -0400 Subject: [PATCH 3/3] fix issue #198 --- plotly/plotlyfig.m | 9 ++ plotly/plotlyfig_aux/core/updateData.m | 3 + .../updateCategoricalHistogram.m | 145 ++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 7e5801a6..2bd0769d 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -623,6 +623,9 @@ function validate(obj) for n = 1:obj.State.Figure.NumAxes try updateAxis(obj,n); + catch + % TODO to the future + disp('warning: error in updateAxis') end end @@ -635,6 +638,9 @@ function validate(obj) obj.data{1, n}.opacity = 0.9; obj.data{1, n}.marker.color = 'rgb(0,113.985,188.955)'; end + catch + % TODO to the future + disp('warning: error using update_opac') end end @@ -643,6 +649,9 @@ function validate(obj) for n = 1:obj.State.Figure.NumTexts try updateAnnotation(obj,n); + catch + % TODO to the future + disp('warning: error in updateAnnotation') end end diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 23d78825..1fb8b581 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -11,6 +11,8 @@ updateImage(obj, dataIndex); case 'line' updateLineseries(obj, dataIndex); + case 'categoricalhistogram' + updateCategoricalHistogram(obj, dataIndex); case 'histogram' if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes') updateHistogramPolar(obj, dataIndex); @@ -128,6 +130,7 @@ end catch % TODO to the future + disp('waring: error in updateData at AXIS/DATA CLEAN UP section') end %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m new file mode 100644 index 00000000..3e3feb03 --- /dev/null +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -0,0 +1,145 @@ +function obj = updateCategoricalHistogram(obj,histIndex) + +% x:...[DONE] +% y:...[DONE] +% histnorm:...[DONE] +% name:...[DONE] +% autobinx:...[DONE] +% nbinsx:...[DONE] +% xbins:...[DONE] +% autobiny:...[DONE] +% nbinsy:...[DONE] +% ybins:...[DONE] +% text:...[NOT SUPPORTED IN MATLAB] +% error_y:...[HANDLED BY ERRORBARSERIES] +% error_x:...[HANDLED BY ERRORBARSERIES] +% opacity: --- [TODO] +% xaxis:...[DONE] +% yaxis:...[DONE] +% showlegend:...[DONE] +% stream:...[HANDLED BY PLOTLYSTREAM] +% visible:...[DONE] +% type:...[DONE] +% orientation:...[DONE] + +% MARKER: +% color: ...[DONE] +% size: ...[NA] +% symbol: ...[NA] +% opacity: ...[TODO] +% sizeref: ...[NA] +% sizemode: ...[NA] +% colorscale: ...[NA] +% cauto: ...[NA] +% cmin: ...[NA] +% cmax: ...[NA] +% outliercolor: ...[NA] +% maxdisplayed: ...[NA] + +% MARKER LINE: +% color: ...[DONE] +% width: ...[DONE] +% dash: ...[NA] +% opacity: ...[TODO] +% shape: ...[NA] +% smoothing: ...[NA] +% outliercolor: ...[NA] +% outlierwidth: ...[NA] + +%-------------------------------------------------------------------------% + +%-AXIS INDEX-% +axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); + +%-HIST DATA STRUCTURE- % +hist_data = get(obj.State.Plot(histIndex).Handle); + +%-CHECK FOR MULTIPLE AXES-% +[xsource, ysource] = findSourceAxis(obj,axIndex); + +%-AXIS DATA-% +eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); +eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); + +%-------------------------------------------------------------------------% + +%-hist xaxis-% +obj.data{histIndex}.xaxis = ['x' num2str(xsource)]; + +%-------------------------------------------------------------------------% + +%-hist yaxis-% +obj.data{histIndex}.yaxis = ['y' num2str(ysource)]; + +%-------------------------------------------------------------------------% + +%-bar type-% +obj.data{histIndex}.type = 'bar'; + +%-------------------------------------------------------------------------% + +%-hist data-% +obj.data{histIndex}.width = hist_data.BarWidth; +obj.data{histIndex}.y = hist_data.BinCounts; + +%-------------------------------------------------------------------------% + +%-hist categorical layout on x-axis-% +obj.layout.xaxis1.type = 'category'; +obj.layout.xaxis1.autotick = false; + +gap = 1 - hist_data.BarWidth; +xmin = -0.5 * gap; +xmax = (hist_data.NumDisplayBins - 1) + 0.5 * gap; + +obj.layout.xaxis1.range = {xmin, xmax}; + +%-------------------------------------------------------------------------% + +%-hist name-% +obj.data{histIndex}.name = hist_data.DisplayName; + +%-------------------------------------------------------------------------% + +%-layout barmode-% +obj.layout.barmode = 'group'; + +%-------------------------------------------------------------------------% + +%-hist line width-% +obj.data{histIndex}.marker.line.width = hist_data.LineWidth; + +%-------------------------------------------------------------------------% + +%-hist opacity-% +if ~ischar(hist_data.FaceAlpha) + obj.data{histIndex}.opacity = hist_data.FaceAlpha; +end + +%-------------------------------------------------------------------------% + +obj.data{histIndex}.marker = extractPatchFace(hist_data); + +%-------------------------------------------------------------------------% + +%-hist visible-% +obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); + +%-------------------------------------------------------------------------% + +%-hist showlegend-% +leg = get(hist_data.Annotation); +legInfo = get(leg.LegendInformation); + +switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; +end + +obj.data{histIndex}.showlegend = showleg; + +%-------------------------------------------------------------------------% + +end