subplot中的图例

本文详细介绍了在MATLAB中如何在subplot环境下添加和定制图例,包括位置、样式和内容的设置,帮助读者更好地组织多图显示并清晰标识每个子图的数据含义。
%% 根据云参数,生成云滴 ( 降水指标 )
clc;  clear;  close all;
DropN = 3000;   % 需要产生的云滴数目
Ex = [0.974738631575396,0.885884456986287,1.51764167435718,3.50383459588321,0.283601590079623;3.06679138513355,1.23197926358265,4.70566433440631,10.5534827517891,1.84722222222222;6.84029258893687,1.54887884409856,10.1471948371156,22.7961185132027,7.06362063214260];
En = [0.697350917852717,0.115364935532121,1.06267422001638,2.34988271863529,0.521206877380866;1.25783373460111,0.105633193505304,1.81384350090311,4.08087858713788,1.73879946997346;1.25783373460111,0.105633193505304,1.81384350090311,4.08087858713788,1.73879946997346];
He = [0.0697350917852717,0.0115364935532121,0.106267422001638,0.234988271863529,0.0521206877380866;0.125783373460111,0.0105633193505304,0.181384350090311,0.408087858713788,0.173879946997346;0.125783373460111,0.0105633193505304,0.181384350090311,0.408087858713788,0.173879946997346];
xrmin = [0, 0.5, 0, 0, 0];       
xrmax = [8, 2, 13, 27, 10];
txtx = [0, 0.5, 0, 0, 0];
txts = {('(a1)')  ('(a2)')  ('(a3)')  ('(a4)')  ('(a5)')};
pclr = hsv(3);  % 颜色条
for   i =1:3  % 画第1subplot('Position',[0.1+0.3*(i-1) 0.7 0.25 0.25]) % 定位坐标位置及大小
       for  j =1:3  
             ex = Ex( j, i );
             en = En( j, i );
             he = He( j, i );
             Enp = normrnd(en, he,  DropN, 1);
             tmp = normrnd(ex, Enp, DropN, 1);
             miu = exp(-0.5*((tmp-ex)./Enp).^2);         
             if   j ==1
                  site = find(tmp<ex);
                  miu(site) = 1;
             end
             if  j == 3
                  site = find(tmp>ex);
                  miu(site) = 1;
             end
             set(gcf,'color',[1,1,1])
             scatter(tmp, miu, 3, pclr(j,:), 'filled','MarkerFaceAlpha',0.7);
             set(gca,'LineWidth',1.0,'Fontname','Times New Roman','FontWeight','Bold','FontSize',14)
             text(txtx(i), 1.08 ,txts(i) ,'color','k','FontName','Times New Roman','FontSize',12)
             xlim([xrmin(i), xrmax(i)]);        
             hold on; box on; 
       end   
end

for   i =4:5  % 画第2subplot('Position',[0.1+0.3*(i-4) 0.37 0.25 0.25]) % 定位坐标位置及大小
       for  j =1:3  
             ex = Ex( j, i );
             en = En( j, i );
             he = He( j, i );
             Enp = normrnd(en, he,  DropN, 1);
             tmp = normrnd(ex, Enp, DropN, 1);
             miu = exp(-0.5*((tmp-ex)./Enp).^2);         
             if   j ==1
                  site = find(tmp<ex);
                  miu(site) = 1;
             end
             if  j == 3
                  site = find(tmp>ex);
                  miu(site) = 1;
             end
             set(gcf,'color',[1,1,1])
             h(j) =  scatter(tmp, miu, 3, pclr(j,:), 'filled','MarkerFaceAlpha',0.7);  % 赋值给句柄,方便后面加图例
             set(gca,'LineWidth',1.0,'Fontname','Times New Roman','FontWeight','Bold','FontSize',14)
             text(txtx(i), 1.08 ,txts(i) ,'color','k','FontName','Times New Roman','FontSize',12)
             xlim([xrmin(i), xrmax(i)]);        
             hold on; box on; 
       end   
end
legd = legend([h(1),h(2),h(3)],{'I','II','III'},'Box','off','Color','w','Position',[0.75 0.45 0.1 0.1],'FontSize',14); % 设置图例属性

看图例

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大雨海深

感谢您的支持和鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值