Mercurial > octave
comparison scripts/plot/draw/bar.m @ 29071:d2f7fb06bce3
Fixed stacked bar chart handling of negative values (bug #58216)
* NEWS: Added note about bar and barh matching Matlab output to Matlab
compatibility section.
* __bar__.m: Updated input parsing to separately handle negative stacked
values.
* bar.m, barh.m: Added demo and input error handling BISTS.
* * *
(bug #58216)
author | Nicholas R. Jankowski <jankowskin@asme.org> |
---|---|
date | Tue, 17 Nov 2020 15:52:03 -0500 |
parents | 9342688e86b4 |
children | 8bb14f4979ca |
comparison
equal
deleted
inserted
replaced
29070:ab3e0676b8d6 | 29071:d2f7fb06bce3 |
---|---|
122 function varargout = bar (varargin) | 122 function varargout = bar (varargin) |
123 varargout = cell (nargout, 1); | 123 varargout = cell (nargout, 1); |
124 [varargout{:}] = __bar__ (true, "bar", varargin{:}); | 124 [varargout{:}] = __bar__ (true, "bar", varargin{:}); |
125 endfunction | 125 endfunction |
126 | 126 |
127 | |
128 %!demo | 127 %!demo |
129 %! clf; | 128 %! clf; |
130 %! y = rand (11, 1); | 129 %! y = rand (11, 1); |
131 %! h = bar (y); | 130 %! h = bar (y); |
132 %! set (h, "ydata", sort (rand (11, 1))); | 131 %! set (h, "ydata", sort (rand (11, 1))); |
142 | 141 |
143 %!demo | 142 %!demo |
144 %! clf; | 143 %! clf; |
145 %! h = bar (rand (5, 3), "stacked"); | 144 %! h = bar (rand (5, 3), "stacked"); |
146 %! title ("bar() graph with stacked style"); | 145 %! title ("bar() graph with stacked style"); |
146 | |
147 %!demo | |
148 %! clf; | |
149 %! y = -rand (3) .* eye (3) + rand (3) .* (! eye (3)); | |
150 %! h = bar (y, "stacked"); | |
151 %! title ("stacked bar() graph including intermingled negative values"); | |
152 | |
153 %% Test input validation | |
154 %!error bar () | |
155 %!error <Y must be numeric> bar ("foo") | |
156 %!error <X must be a vector> bar ([1 2; 3 4], [1 2 3 4]) | |
157 %!error <X vector values must be unique> bar ([1 2 3 3], [1 2 3 4]) | |
158 %!error <length of X and Y must be equal> bar ([1 2 3], [1 2 3 4]) | |
159 %!error <length of X and Y must be equal> bar ([1 2 3 4], [1 2 3]) |