您的位置:首页 > 编程语言 > MATLAB

matlab中画折线/柱状图(横坐标为字符串、及其它注意事项)

2015-04-05 10:48 417 查看
%画折线图

x = [1 2 3 4 5];
y = [2.27 12.60 17.20 14.33 16.03];
hold on;
axis([0 6 0 20]);

plot(x,y,'-*k','LineWidth',2);

%set(gcf, 'color', 'w');

%change the xlabel;
set(gca,'xticklabel',{'','Neutral','Happy','Sad','Anxious','Angry'});

text(1,2.3,'24.35');
text(2,24.2,'23.88');
text(3,24,'23.60');
text(4,24,'23.67');
text(5,25,'24.56');

xlabel('Speech probability','fontsize',15);
ylabel('EER(%)', 'fontsize',15);

% ??

%使图像带箭头
annotation('arrow',[0.132 0.132],[0.8 1]);
annotation('arrow',[0.8 1],[0.108 0.108]);
%set(gca,'box','off','tick',[]);


%画柱状图

%row is for each test
x=[
(14.61-13.36)/14.61 (14.61-12.71)/14.61;
(20.16-17.05)/20.16 (20.16-16.55)/20.16;
(17.30-16.30)/17.30 (17.30-15.65)/17.30;
(18.55-16.55)/18.55 (18.55-16.05)/18.55;
]

%hold on;

b = bar(x);

ch = get(b,'children');
%set color:
set(b(1),'facecolor',[0.6 0 0]);
set(ch{1},'facecolor',[0.81 0 0]);
set(b(2),'facecolor',[0 0 0.8]);
set(ch{2},'facecolor',[0 0 0.8]);

%set background-color
set(gcf, 'color', 'w');
legend('MLLR', 'CMLLR');

%set x/ylim
xlim([0,5]);
ylim([0,0.3])

%set x-label
lab={'Happy', 'Sad', 'Anxious', 'Angry'};
set(gca,'XTickLabel',lab, 'xTick', 1:numel(lab)) ;

xlabel('emotional speech', 'fontsize',15);
ylabel('EER(%)', 'fontsize',15);
set(gca,'fontsize', 15);

%applyhatch(gcf,'/\+.-');

annotation('arrow',[0.132 0.132],[0.8 1]);
annotation('arrow',[0.8 1],[0.108 0.108]);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: