matlab-柱状图汇总操作

fs=500:15:590;
yall=[aa;dd];
bar(fs,yall);
xlabel('Fre(Hz)');
ylabel('loss(W)');
legend('FEM','Ana','Location','northwest');
saveas(gcf,'procompare.png')

aa和dd分别是两组柱状图的纵坐标数据。结果如下:

我觉得这个配色,好丑的。。。

顺道把配色改一下吧,这样来:

h1=bar(fs,u);
xlabel('Fre(Hz)')
ylabel('diff(W)')
color_matrix = [58/256,101/256,198/256
                56/256,200/256,145/256]; 
%color_matrix = [117/256,209/256,241/256  %颜色好看
                184/256,234/256,124/256]; 
set(h1(1),'facecolor',color_matrix(1,:))
set(h1(2),'facecolor',color_matrix(2,:))
legend('FEM','NEU','Location','northwest');
set(gca,'fontsize',15,'fontname','Times');  %设置坐标轴字体
saveas(gcf,'onloadcompare.png')

是不是看着顺眼多了,嘿嘿。 

继续在这上面加内容吧,不得不说matlab自带的帮助文档就很nice.

画个简单的堆叠图,然后横坐标改成文字,不要数字。

X = categorical({'hairpin','round','litz'});
X = reordercats(X,{'hairpin','round','litz'});
aform=[6900 2500];
around=[2400 4800];
lize=[0 4500;];
re=[aform;around;lize];
h1=bar(X,re,'stacked');
color_matrix = [58/256,101/256,198/256
                56/256,200/256,145/256]; 
set(h1(1),'facecolor',color_matrix(1,:))
set(h1(2),'facecolor',color_matrix(2,:))
legend('AC loss','DC loss','Location','northeast');
saveas(gcf,'72loss.png')

顺便把双坐标的代码放在这里了

re=[14.18 28.78 32.712];
re1=re/14.18;
X = categorical({'2D','3D-0.4','3D-0.5'});
X = reordercats(X,{'2D','3D-0.4','3D-0.5'});
yyaxis left  %激活左坐标
bar(X,re,0.2);
ylabel('loss(W)');
hold on
yyaxis right  %激活右坐标
plot(re1,'*--','linewidth',2)
ylim([0,2.5]);
ylabel('normalization');
hold off

最后再把三维柱状图的代码补充一下:

zdraw=reshape(z,5,5);
zz=[1,2,3;4,5,6;7,8,9];
color_matrix = [255/255 187/255 0/255];
% h=bar3(y,z,0.5);
h=bar3(zdraw,0.3);
set(h,'facecolor',color_matrix);  %更改柱状图颜色
set(gca,'yticklabel',{'10','20','30','40','50'},'Fontname','Times New Roman','FontSize',11);
set(gca,'xticklabel',{'100','200','300','400','500'},'Fontname','Times New Roman','FontSize',11);

 

  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值