help-octave
[Top][All Lists]
Advanced

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

Re: Stacked bar plot with positive and negative values


From: Tony Richardson
Subject: Re: Stacked bar plot with positive and negative values
Date: Mon, 20 Apr 2020 11:54:53 -0500

On Mon, Apr 20, 2020 at 11:50 AM Nicholas Jankowski <address@hidden> wrote:


Hi Olivier,
Octave's stacked option appears to work differently than Excel.  I prefer Octave's behavior (although it would be considered a bug
if it differs from MATLAB, I don't have MATLAB to check).   It appears that you can get the plot you want by plotting the positive 
and negative values separately:

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

Tony

FYI.  Octave's behavior is consistent with MATLAB's,

Tony 


only for your code.  his original code does produce different results in Matlab and Octave. 


Apparently this was a change introduced in MATLAB 2019b, quoting from the release notes:

"Stacked groups of bars display negative bars below zero, rather than overlapping the bars."

Tony

reply via email to

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