Skip to content

Commit 56d698f

Browse files
fix issue #196
1 parent 0f006a7 commit 56d698f

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

plotly/plotlyfig.m

+8-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@
265265

266266
% strip the style keys from data
267267
for d = 1:length(obj.data)
268-
if strcmpi(obj.data{d}.type, 'scatter')
268+
if ( ...
269+
strcmpi(obj.data{d}.type, 'scatter') || ...
270+
strcmpi(obj.data{d}.type, 'bar') ...
271+
)
269272
return
270273
end
271274
obj.data{d} = obj.stripkeys(obj.data{d}, obj.data{d}.type, 'style');
@@ -889,7 +892,10 @@ function delete(obj)
889892
catch exception
890893
if obj.UserData.Verbose
891894
% catch 3D output until integrated into graphref
892-
if ~(strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') || strcmpi(fieldname,'mesh3d'))
895+
if ~( ...
896+
strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ...
897+
|| strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ...
898+
)
893899
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
894900
end
895901
end

plotly/plotlyfig_aux/handlegraphics/updateHistogram.m

+6-17
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,8 @@
7373

7474
%-------------------------------------------------------------------------%
7575

76-
%-hist type-%
77-
obj.data{histIndex}.type = 'histogram';
78-
79-
%-------------------------------------------------------------------------%
80-
81-
%-HIST XAXIS-%
82-
obj.data{histIndex}.histfunc= 'count';
76+
%-bar type-%
77+
obj.data{histIndex}.type = 'bar';
8378

8479
%-------------------------------------------------------------------------%
8580

@@ -93,19 +88,13 @@
9388

9489
switch orientation
9590
case {'vertical', 'horizontal'}
96-
% histogram()
97-
98-
obj.data{histIndex}.x = sort(hist_data.Data.');
99-
obj.data{histIndex}.autobinx = false;
100-
101-
obj.data{histIndex}.xbins.start = hist_data.BinEdges(1);
102-
obj.data{histIndex}.xbins.end = hist_data.BinEdges(end);
103-
obj.data{histIndex}.xbins.size = mean(hist_data.BinEdges(2:end)-hist_data.BinEdges(1:end-1));
10491

10592
%-------------------------------------------------------------------------%
93+
%-hist y data-%
10694

107-
%-layout bargap-%
108-
obj.layout.bargap = 0;
95+
obj.data{histIndex}.x = hist_data.BinEdges(1:end-1) + 0.5*diff(hist_data.BinEdges);
96+
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);
10998

11099
%-------------------------------------------------------------------------%
111100

0 commit comments

Comments
 (0)