matlab绘制柱状图 学术论文

% 创建多组数据
MPD = [0.61 0.33 0.24;1.49 1.38 0.97 ; 2.60 2.34 1.97 ; 2.89 2.79 2.10];
% 使用 bar 函数绘制多组柱状图
b=bar(MPD,'FaceColor','flat','BarWidth',0.9);
%% 使用 bar 函数绘制多组柱状图
% % % color = [216 208 143; 165 170 78; 172 71 101]/255;
% % % % b = bar(y,'FaceColor','flat');
% % % for k = 1:size(MPD,2)
% % %     b(k).CData = color(k,:);
% % % end

% 添加标题和标签
% title('多组柱状图示例');
% xlabel('数据点');
ylabel('MPD / (%)');
% 设置 x 轴刻度标签
ab=32;
ac=24;
set(gca, 'XTickLabel', {'Load-1', 'Load-2','Load-3', 'Load-4'});
set(gca,'FontSize',ab);
%% 显示网格线
ax = gca; % current axes
ax.XGrid = 'off';
ax.YGrid = 'on';
set(ax,'XColor','black','LineWidth',4); 
set(ax,'YColor','black','LineWidth',4); 
%% 显示图例
legend('iFEM-iQS4', 'iLRPIM-2ed','iLRPIM-4th');
% 隐藏图例的边框
legend('box', 'off');
%% 添加柱状图顶的数字
xtips1 = b(1).XEndPoints;
ytips1 = b(1).YEndPoints;
labels1 = string(b(1).YData);
text(xtips1,ytips1,labels1,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',ac)
xtips2 = b(2).XEndPoints;
ytips2 = b(2).YEndPoints;
labels2 = string(b(2).YData);
text(xtips2,ytips2,labels2,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',ac)
xtips3 = b(3).XEndPoints;
ytips3 = b(3).YEndPoints;
labels3 = string(b(3).YData);
text(xtips3,ytips3,labels3,'HorizontalAlignment','center',...
    'VerticalAlignment','bottom','FontSize',ac)

% 设置 y 轴范围为 0 到 70
ylim([0, 2*max(max(MPD))]);

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值