diff 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
line wrap: on
line diff
--- a/scripts/plot/draw/bar.m	Wed Nov 18 19:45:04 2020 -0800
+++ b/scripts/plot/draw/bar.m	Tue Nov 17 15:52:03 2020 -0500
@@ -124,7 +124,6 @@
   [varargout{:}] = __bar__ (true, "bar", varargin{:});
 endfunction
 
-
 %!demo
 %! clf;
 %! y = rand (11, 1);
@@ -144,3 +143,17 @@
 %! clf;
 %! h = bar (rand (5, 3), "stacked");
 %! title ("bar() graph with stacked style");
+
+%!demo
+%! clf;
+%! y = -rand (3) .* eye (3) + rand (3) .* (! eye (3));
+%! h = bar (y, "stacked");
+%! title ("stacked bar() graph including intermingled negative values");
+
+%% Test input validation
+%!error bar ()
+%!error <Y must be numeric> bar ("foo")
+%!error <X must be a vector> bar ([1 2; 3 4], [1 2 3 4])
+%!error <X vector values must be unique> bar ([1 2 3 3], [1 2 3 4])
+%!error <length of X and Y must be equal> bar ([1 2 3], [1 2 3 4])
+%!error <length of X and Y must be equal> bar ([1 2 3 4], [1 2 3])