Skip to content

Commit 9f51358

Browse files
Merge pull request #365 from plotly/fix_issues_with_histogram_function_in_ssim_baselines_matlab_code-examples_data-distribution-plots_histogram
fix issues with histogram function in ssim_baselines/matlab/code-examples/data-distribution-plots/histogram/
2 parents f155efb + faac9bf commit 9f51358

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

plotly/plotlyfig_aux/core/updateData.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
updateLineseries(obj, dataIndex);
2020
elseif strcmpi(obj.PlotOptions.TreatAs, 'ezpolar')
2121
updateLineseries(obj, dataIndex);
22+
elseif strcmpi(obj.PlotOptions.TreatAs, 'polarhistogram')
23+
updateHistogramPolar(obj, dataIndex);
24+
25+
% this one will be revomed
2226
elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube')
2327
updateStreamtube(obj, dataIndex);
2428
end
@@ -43,11 +47,7 @@
4347
case 'categoricalhistogram'
4448
updateCategoricalHistogram(obj, dataIndex);
4549
case 'histogram'
46-
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
47-
updateHistogramPolar(obj, dataIndex);
48-
else
49-
updateHistogram(obj, dataIndex);
50-
end
50+
updateHistogram(obj, dataIndex);
5151
case 'histogram2'
5252
updateHistogram2(obj, dataIndex);
5353
case 'patch'

plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@
8080

8181
%-hist data-%
8282
obj.data{histIndex}.width = hist_data.BarWidth;
83-
obj.data{histIndex}.y = hist_data.BinCounts;
83+
obj.data{histIndex}.y = hist_data.Values;
8484

8585
%-------------------------------------------------------------------------%
8686

8787
%-hist categorical layout on x-axis-%
88-
obj.layout.xaxis1.type = 'category';
89-
obj.layout.xaxis1.autotick = false;
90-
9188
gap = 1 - hist_data.BarWidth;
92-
xmin = -0.5 * gap;
93-
xmax = (hist_data.NumDisplayBins - 1) + 0.5 * gap;
89+
xmin = -gap;
90+
xmax = (hist_data.NumDisplayBins - 1) + gap;
9491

95-
obj.layout.xaxis1.range = {xmin, xmax};
92+
t = 'category';
93+
eval(['obj.layout.xaxis' num2str(xsource) '.type = t;']);
94+
eval(['obj.layout.xaxis' num2str(xsource) '.autotick = false;']);
95+
eval(['obj.layout.xaxis' num2str(xsource) '.range = {xmin, xmax};']);
9696

9797
%-------------------------------------------------------------------------%
9898

@@ -113,7 +113,7 @@
113113

114114
%-hist opacity-%
115115
if ~ischar(hist_data.FaceAlpha)
116-
obj.data{histIndex}.opacity = hist_data.FaceAlpha;
116+
obj.data{histIndex}.opacity = 1.25*hist_data.FaceAlpha;
117117
end
118118

119119
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/handlegraphics/updateHistogram.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494

9595
obj.data{histIndex}.x = hist_data.BinEdges(1:end-1) + 0.5*diff(hist_data.BinEdges);
9696
obj.data{histIndex}.width = diff(hist_data.BinEdges);%[hist_data.BinEdges(2:end), hist_data.Data(end)];
97-
obj.data{histIndex}.y = double(hist_data.BinCounts);
97+
obj.data{histIndex}.y = double(hist_data.Values);
9898

9999
%-------------------------------------------------------------------------%
100100

@@ -186,7 +186,7 @@
186186

187187
%-hist opacity-%
188188
if ~ischar(hist_data.FaceAlpha)
189-
obj.data{histIndex}.opacity = hist_data.FaceAlpha;
189+
obj.data{histIndex}.opacity = hist_data.FaceAlpha * 1.25;
190190
end
191191

192192
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/helpers/extractPatchFace.m

+1-6
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@
4444
capCD = max(min(patch_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1));
4545
scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim);
4646
col = 255*(colormap(1+ floor(scalefactor*(length(colormap)-1)),:));
47-
case 'direct'
47+
case {'direct', 'auto'}
4848
col = 255*(colormap(patch_data.FaceVertexCData(1,1),:));
4949

5050
end
5151

5252
marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
53-
54-
case 'auto'
55-
marker.color = 'rgb(0,113.985,188.955)';
56-
5753
end
5854
end
5955

@@ -64,7 +60,6 @@
6460

6561
col = 255*patch_data.EdgeColor;
6662
marker.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
67-
6863
else
6964
switch patch_data.EdgeColor
7065

0 commit comments

Comments
 (0)