-
Notifications
You must be signed in to change notification settings - Fork 0
/
histogram.m
68 lines (64 loc) · 1.74 KB
/
histogram.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function h = histogram(ax,x,varargin)
%HISTOGRAM Return default histogram object for given axes and data
%
% h = default.histogram(x); % -> Sets ax using `default.axes()`
% h = default.histogram(ax,x);
% h = default.histogram(ax,x,'Name',value,...);
%
% Inputs
% name - Name of figure ('Name' figure property)
% varargin - 'Name',value keyword argument pairs for Matlab axes builtin
%
% Output
% h - Formatted Matlab histogram primitive chart object handle
%
% See also: Contents, matlab.graphics.chart.primitive.Histogram
switch nargin
case 0
ax = default.axes();
x = nan(1,2);
name = 'Untitled';
case 1
if isa(ax,'matlab.graphics.axis.Axes')
x = nan(1,2);
name = ax.Tag;
elseif isa(ax,'char') || isa(ax,'string')
varargin = [ax, varargin];
ax = default.axes();
x = nan(1,2);
name = 'Untitled';
else
x = ax;
ax = default.axes();
name = inputname(1);
end
otherwise
if isa(ax,'matlab.graphics.axis.Axes')
if ~isnumeric(x)
varargin = [x, varargin];
x = nan(1,2);
name = 'Untitled';
else
name = inputname(2);
end
elseif isa(ax,'char') || isa(ax,'string')
varargin = [ax, x, varargin];
ax = default.axes();
x = nan(1,2);
name = 'Untitled';
else
varargin = [x, varargin];
x = ax;
ax = gca;
name = inputname(1);
end
end
h = histogram(ax,x,...
'Tag',sprintf('Histogram-%02d',numel(ax.Children)+1),...
'DisplayName',name,...
'FaceColor','#444',...
'EdgeColor','#666',...
'FaceAlpha',0.6,...
'EdgeAlpha',0.8,...
varargin{:});
end