plot_contributions.m: compatibility fixes for Octave
— use zeros instead of NaNs when decomposing between positive and negative contributions; otherwise some contributions are not plotted — the bar() function returns a column-vector of graphic handles, while on MATLAB it returs a row-vectortime-shift
parent
5da473ac66
commit
3e6224e0b6
|
@ -186,8 +186,8 @@ hold on
|
||||||
cc = contribution(:,2:end);
|
cc = contribution(:,2:end);
|
||||||
|
|
||||||
% Limit the matrices to what we care about
|
% Limit the matrices to what we care about
|
||||||
ccneg = cc(:,1:length(vnames)); ccneg(ccneg>=0) = nan;
|
ccneg = cc(:,1:length(vnames)); ccneg(ccneg>=0) = 0;
|
||||||
ccpos = cc(:,1:length(vnames)); ccpos(ccpos<0) = nan;
|
ccpos = cc(:,1:length(vnames)); ccpos(ccpos<0) = 0;
|
||||||
H = bar(1:ds.nobs, ccneg, 'stacked');
|
H = bar(1:ds.nobs, ccneg, 'stacked');
|
||||||
if ~isoctave && ~matlab_ver_less_than('9.7')
|
if ~isoctave && ~matlab_ver_less_than('9.7')
|
||||||
% For MATLAB ≥ R2019b, use the same color indexing scheme as with older releases
|
% For MATLAB ≥ R2019b, use the same color indexing scheme as with older releases
|
||||||
|
@ -201,5 +201,9 @@ lhs = strrep(lhs, '_', '\_');
|
||||||
title(sprintf('Decomposition of %s', lhs))
|
title(sprintf('Decomposition of %s', lhs))
|
||||||
|
|
||||||
vnames = strrep(vnames,'_','\_');
|
vnames = strrep(vnames,'_','\_');
|
||||||
legend([H, line_], [vnames, lhs], 'location', 'northwest');
|
if ~isoctave
|
||||||
|
legend([H, line_], [vnames, lhs], 'location', 'northwest');
|
||||||
|
else
|
||||||
|
% Under Octave, H is a column vector
|
||||||
|
legend([H; line_], [vnames, lhs], 'location', 'northwest');
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue