Matlab outcome is different between online version and 2019a version

Viewed 156

I have stacked bar codes that I want to see negative values below zero. When I use MATLAB online version I can get what I want but when I perform it on my computer it doesn't differentiate between positive and negative value. I am using MATLAB 2019a.

scaleaccretdecm(1:52, 1)=[0.024385606   0.022413488 0.044662561 0.003465332 0.020993959 0.032899477 0.030234633 0.049393371 0.045227192 0.042258106 0.065216925 0.060235394 0.050300704 0.059009665 0.044761431 0.032358603 0.012341471 0.019592291 0.040222551 0.029380475 0.037589868 0.046407316 0.077936607 0.107160264 0.096636333 0.0878621   0.108100764 0.075800066 0.118804893 0.108354917 0.121995114 0.145283354 0.156555518 0.175677074 0.201213601 0.220005439 0.167424693 0.183198114 0.188126781 0.199241433 0.229967391 0.232639002 0.228793215 0.228090775 0.229343472 0.217403674 0.237397605 0.247221671 0.260484612 0.292758388 0.28522593  0.269695308];
scaleaccretdecm(1:52, 2)=[-0.009871475  -0.005268862    0.001091759 0.034312917 0.029936851 0.042577605 0.052247005 0.035380186 0.032435718 0.074918233 0.038400657 0.024173677 0.058605382 0.049289806 0.052726973 0.059984301 0.078675061 0.075863711 0.053860121 0.062903069 0.064338411 0.078853407 0.052406498 0.023773216 0.037638943 0.053554811 0.02469932  0.045283892 0.026318071 0.030571141 0.030920266 0.020580842 0.004162456 -0.002937019    -0.023951657    -0.036207684    -0.05364969 -0.06978204 -0.049198249    -0.047269172    -0.042161151    -0.060016701    -0.042602654    -0.057791123    -0.050319653    -0.048266361    -0.04358329 -0.047806285    -0.031104006    -0.053715053    -0.03760559 -0.024190423];
scaleaccretdecm(1:52, 3)=[-0.011056757  -0.006954471    -0.002173208    0.009260237 0.00265849  0.003678591 0.006136322 -0.004435098    -0.008606409    0.002194055 -0.011360281    -0.014624702    -0.004002074    -0.009218405    -0.006049953    -8.56E-05   0.004971094 0.004898834 -0.00464586 0.000610642 0.000701145 0.004663761 -0.004330913    -0.017295049    -0.01253931 -0.007307185    -0.019971941    -0.011727831    -0.017468372    -0.015775705    -0.015876961    -0.021131038    -0.029309852    -0.029977501    -0.039566658    -0.04216126 -0.041484996    -0.043002834    -0.038862395    -0.037267353    -0.034064608    -0.039055899    -0.032824281    -0.037671632    -0.034290661    -0.034069499    -0.03312865 -0.034882352    -0.031628822    -0.038194886    -0.030256354    -0.027014841];

figure;
hold on; 
t = datetime(2001,1,5) + calweeks(1:52);
bar(t,scaleaccretdecm(1:52, 1:3),.99,"stacked");
hold on;
bar(t,-scaleaccretdecm(1:52, 1:3),.001,"stacked"); %legend(txt(16:18),'Location','southoutside');
ylim([-.5 .5]);
hold on;
saveas(gcf,'AccumReturns.png');
hold off;

MATLAB online

MATLAB2019a

1 Answers

In the MATLAB Release Notes for R2019b you can read:

The bar and barh functions have these improvements:

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

That is, this is a change introduced in R2019b (MATLAB Online always uses the latest version). Thus, if you want to recreate these graphs on your desktop, you will have to upgrade your version of MATLAB.

Related