octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #58216] bar: stacked bar chart improperly hand


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #58216] bar: stacked bar chart improperly handles negative values
Date: Mon, 20 Apr 2020 12:16:49 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?58216>

                 Summary: bar: stacked bar chart improperly handles negative
values
                 Project: GNU Octave
            Submitted by: nrjank
            Submitted on: Mon 20 Apr 2020 12:16:48 PM EDT
                Category: Plotting
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Nicholas Jankowski
        Originator Email: 
             Open/Closed: Open
                 Release: 5.2.0
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

as reported on the mailing list [1], attempting to plot a stacked bar with
negative values in the data array produces a plot where the negative element
overlaps the rest of the data.  this behavior differs from Matlab which
displays the 'expected' stacked bar with one value extending to the negative
range.

E.g., the following all positive value input produces expected outputs
identical in both programs except for a different colormap:


z = [1 2 3; 4 5 6];
h = bar (z, 'stacked');


see Stacked_allPos.PNG

however, the following does not:

z = [1 -2 3; 4 5 6];
h = bar (z, 'stacked');


see Stacked_oneNeg.PNG

Based on the color scheme, it appears that the Octave output creates the +1,
then a negative two from the top of that (extending to -1) then a +3, with the
final and only visible block going from -1 to 2.  

In Matlab 2020a, it produces a block from 0 to 1, a second block from 0 to -2,
and a third block from 1 to 4.  It appears any negative values are treated as
independent 'negative bars' starting from zero.  can confirm this with a 


z=[1 -2 3 -4; 1 4 5 6];
h = bar (z, 'stacked');


see Stacked_twoNeg.PNG

where matlab has the 1 and 3 bars stacked on the positive side and the -2 and
-4 bars stacked on the negative side, both extending from zero.

for the time being, a workaround was proposed that produces identical plots by
holding the fig and issuing two bar commands:


z=[1 -2 3;  4 3 1]
zt = z;
zt(zt<0) = 0
h = bar (zt, 'stacked');
hold on
zt = z;
zt(zt>0) = 0
h = bar (zt, 'stacked');
hold off


see Stacked_workaround.PNG

See attached figures. (does anyone know how to embed an image in an initial
report before a file # has been generated?)

[1]
https://octave.1599824.n4.nabble.com/Stacked-bar-plot-with-positive-and-negative-values-tp4696772.html



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mon 20 Apr 2020 12:16:48 PM EDT  Name: Stacked_allPos.PNG  Size: 50KiB  
By: nrjank
images demonstrating stacked bar chart negative value incompatibilites
<http://savannah.gnu.org/bugs/download.php?file_id=48882>
-------------------------------------------------------
Date: Mon 20 Apr 2020 12:16:48 PM EDT  Name: Stacked_twoNeg.PNG  Size: 49KiB  
By: nrjank
images demonstrating stacked bar chart negative value incompatibilites
<http://savannah.gnu.org/bugs/download.php?file_id=48883>
-------------------------------------------------------
Date: Mon 20 Apr 2020 12:16:48 PM EDT  Name: Stacked_oneNeg.PNG  Size: 54KiB  
By: nrjank
images demonstrating stacked bar chart negative value incompatibilites
<http://savannah.gnu.org/bugs/download.php?file_id=48884>
-------------------------------------------------------
Date: Mon 20 Apr 2020 12:16:48 PM EDT  Name: Stacked_workaround.PNG  Size:
39KiB   By: nrjank
images demonstrating stacked bar chart negative value incompatibilites
<http://savannah.gnu.org/bugs/download.php?file_id=48885>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58216>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]