Bar plot error using text function
이전 댓글 표시
Hi,
A friend with (Matlab2017) gave me this code:
label = categorical({'IBS';'ZEN';'RE';'LRS';'SEASONAL';'AAA';'COMBOCOMM';'A30';'BALANCE'});
temp = [ibs_perf; zen_perf; re_perf; lrs_perf; sea_perf; aaa_perf; com_perf; a30_perf; bal_perf];
bar(label,diag(temp),0.5,'stacked')
title('Strategies Performance Attribution','FontSize', 16)
set(gcf, 'Position', get(0, 'Screensize'));
grid on
grid minor
ylim([ylim2-0.1 ylim1+0.1])
lim = get(gca,'ytick');
a=[cellstr(num2str(get(gca,'ytick')'))];
pct = char(ones(size(a,1),1)*'%');
new_yticks = [char(a),pct];
set(gca,'yticklabel',new_yticks)
for i = 1:size(temp,1)
if temp(i,1) >= 0
text(label(i,1),temp(i,1),strcat(num2str(temp(i,1),'%0.2f'),'%'),...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom')
else
text(label(i,1),temp(i,1),strcat(num2str(temp(i,1),'%0.2f'),'%'),...
'HorizontalAlignment','center',...
'VerticalAlignment','top')
end
end
In my Matlab 2016a I recive this error:
Error using text
First two or three arguments must be numeric doubles.
How Can I fix the problem?
Thanks!!!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!