From faac9bfe7e49be1c184d4bc55e3abfa8016605a6 Mon Sep 17 00:00:00 2001 From: Gilberto Galvis Date: Fri, 27 Aug 2021 21:15:50 -0400 Subject: [PATCH] fix issues with histogram function in ssim_baselines/matlab/code-examples/data-distribution-plots/histogram/ --- plotly/plotlyfig_aux/core/updateData.m | 10 +++++----- .../handlegraphics/updateCategoricalHistogram.m | 16 ++++++++-------- .../handlegraphics/updateHistogram.m | 4 ++-- plotly/plotlyfig_aux/helpers/extractPatchFace.m | 7 +------ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 6b0c76ee..4bb25cec 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -19,6 +19,10 @@ updateLineseries(obj, dataIndex); elseif strcmpi(obj.PlotOptions.TreatAs, 'ezpolar') updateLineseries(obj, dataIndex); + elseif strcmpi(obj.PlotOptions.TreatAs, 'polarhistogram') + updateHistogramPolar(obj, dataIndex); + + % this one will be revomed elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube') updateStreamtube(obj, dataIndex); end @@ -43,11 +47,7 @@ case 'categoricalhistogram' updateCategoricalHistogram(obj, dataIndex); case 'histogram' - if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes') - updateHistogramPolar(obj, dataIndex); - else - updateHistogram(obj, dataIndex); - end + updateHistogram(obj, dataIndex); case 'histogram2' updateHistogram2(obj, dataIndex); case 'patch' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index 3e3feb03..458ddf03 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -80,19 +80,19 @@ %-hist data-% obj.data{histIndex}.width = hist_data.BarWidth; -obj.data{histIndex}.y = hist_data.BinCounts; +obj.data{histIndex}.y = hist_data.Values; %-------------------------------------------------------------------------% %-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; +xmin = -gap; +xmax = (hist_data.NumDisplayBins - 1) + gap; -obj.layout.xaxis1.range = {xmin, xmax}; +t = 'category'; +eval(['obj.layout.xaxis' num2str(xsource) '.type = t;']); +eval(['obj.layout.xaxis' num2str(xsource) '.autotick = false;']); +eval(['obj.layout.xaxis' num2str(xsource) '.range = {xmin, xmax};']); %-------------------------------------------------------------------------% @@ -113,7 +113,7 @@ %-hist opacity-% if ~ischar(hist_data.FaceAlpha) - obj.data{histIndex}.opacity = hist_data.FaceAlpha; + obj.data{histIndex}.opacity = 1.25*hist_data.FaceAlpha; end %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m index 0c4fb170..91b636b1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m @@ -94,7 +94,7 @@ obj.data{histIndex}.x = hist_data.BinEdges(1:end-1) + 0.5*diff(hist_data.BinEdges); obj.data{histIndex}.width = diff(hist_data.BinEdges);%[hist_data.BinEdges(2:end), hist_data.Data(end)]; - obj.data{histIndex}.y = double(hist_data.BinCounts); + obj.data{histIndex}.y = double(hist_data.Values); %-------------------------------------------------------------------------% @@ -186,7 +186,7 @@ %-hist opacity-% if ~ischar(hist_data.FaceAlpha) - obj.data{histIndex}.opacity = hist_data.FaceAlpha; + obj.data{histIndex}.opacity = hist_data.FaceAlpha * 1.25; end %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractPatchFace.m b/plotly/plotlyfig_aux/helpers/extractPatchFace.m index 57a9f695..d4b7ef54 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchFace.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchFace.m @@ -44,16 +44,12 @@ capCD = max(min(patch_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1)); scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim); col = 255*(colormap(1+ floor(scalefactor*(length(colormap)-1)),:)); - case 'direct' + case {'direct', 'auto'} col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); end marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - case 'auto' - marker.color = 'rgb(0,113.985,188.955)'; - end end @@ -64,7 +60,6 @@ col = 255*patch_data.EdgeColor; marker.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - else switch patch_data.EdgeColor