【matlab】气泡图的应用

发布于:2025-04-23 ⋅ 阅读:(23) ⋅ 点赞:(0)

【matlab】气泡图的应用

在这里插入图片描述

.rtcContent { padding: 30px; } .lineNode {font-size: 12pt; font-family: "Times New Roman", Menlo, Monaco, Consolas, "Courier New", monospace; font-style: normal; font-weight: normal; }
clear
load zb_equi.mat
load   zb_end.mat
h=1.4;
rate=nan(length(r),length(c0));
for i=1:length(c0)
    x=(0:1:101-1)*dx(i) ;
    x1=x(end)/(zb_equi(1,i)-zb_equi(end,i))*(zb_equi(1,i)+h);
    x3=interp1(zb_equi(:,i),x,h);
    for j=1:length(zb_end{1}(1,:))
         x2=x(end)/(zb_end{i}(1,j)-zb_end{i}(end,j))*(zb_end{i}(1,j)+h);
        x4=interp1(zb_end{i}(:,j),x,h);
        rate(j,i)=((x4-x2)-(x3-x1))/(x3-x1)/13;
    end
end
[xx,yy]=meshgrid(c0*1000,r);
levels = [-0.01 -0.007 -0.005 -0.003 -0.001 -0.0005 0 0.003 0.005 0.01 0.02];
xf=720;
yf=620;
figure('Position', [0, 0, xf, yf])
a=subplot('Position',[0.1*700/xf (0.35*700-80)/yf 0.8*700/xf 0.6*700/yf]);
set(gca,'units','point')
ylim([0 120])
[Cc,c]=contourf(xx,yy,rate,levels);
levels = clabel(Cc,c,'manual','fontsize',11,'color',[0.3 0.3 0.3],'fontname','times new roman');
for i = 1:numel(levels)
    label = sprintf('%g%%', 100*str2double(levels(i).String));
    levels(i).String = label;
end
c.LineWidth = 0.2;
c.LineColor = [0.5 0.5 0.5];
hold on
[C,c1]=contour(xx,yy,rate,[-0.0005 0.003]);
c1.LineColor = [0 0 0];
x1=C(1,2:C(2,1)+1);
y1=C(2,2:C(2,1)+1);
x2=C(1,C(2,1)+3:end);
y2=C(2,C(2,1)+3:end);
x1=[20 x1];
y1=[-0.03 y1];
p3=fill([x1 fliplr(x2)],[y1 fliplr(y2)],'g' , 'EdgeColor',[0 0 0], 'FaceAlpha', 0.1);
plot([50 50],[-0.03 0.03],'--',[75 75],[-0.03 0.03],'--','LineWidth',2,'Color',[.4 .4 .4])
[cmap_smooth] = create_custom_colormap(-0.01, 0.03,[21 151 165]/256, [254 179 174;246 111 105;239 65 67]/256, 40);
h=colorbar('Location', 'east', 'Position', [0.91*700/xf, (0.4*700-80)/yf, 0.03*700/xf, 0.5*700/yf]);
ylabel(h,'Trend of tidal flat width (%/year)','Fontsize',11,'Fontname','times new roman')
colormap(cmap_smooth);
set(gca,'YTickLabel',num2str(get(gca,'YTick')'*100,'%g%%'))
set(gca,'TickLength',[0 0])
xlim([20 120])
ylim([-0.03 0.03])
hold on
%%
clearvars -except h p3 xf yf
table_tidalflat = readtable('China_tidalflat.csv','VariableNamingRule','preserve');
tidalflat = table2array(table_tidalflat);
tidalflat(:,9:10) = tidalflat(:,9:10)/100;
zeroloc=isnan(tidalflat(:,5));
tidalflat(zeroloc,:)=[];
nanloc1=find(isnan(tidalflat(:,6)));
tidalflat(nanloc1,:)=[];
nanloc3=find(isnan(tidalflat(:,10)));
tidalflat(nanloc3,:)=[];
nanloc2=find(isnan(tidalflat(:,9)));
tidalflat(nanloc2,:)=[];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[swh_uni,aa]=unique(tidalflat(:,9),'stable');
tf_unique=nan(length(swh_uni),length(tidalflat(1,:)));
for i=1:length(aa)
    loc=find(tidalflat(:,9)==swh_uni(i));
    slope_loc=tidalflat(loc,:);
    tf_unique(i,:)=mean(slope_loc,1,'omitnan');
end
tf_unique(tf_unique(:,10)>0.2,:)=[];
ssc_vec = tf_unique(:,7);
width_rate_vec = tf_unique(:,10);
ssc_rate_vec = tf_unique(:,9);
ssc_range = [20 60 100 140];
ssc_rate_range=linspace(-0.03,0.03,5);
P2=[];
bili=0.48;
for i = 1:length(ssc_rate_range)-1
    ssc_rate_min = ssc_rate_range(i);
    ssc_rate_max = ssc_rate_range(i+1);
    idx = find(ssc_rate_vec >= ssc_rate_min & ssc_rate_vec <= ssc_rate_max & ssc_vec < 50);
    L=length(idx);
    disp(L)
    if L<15
        continue
    else
    slope_idx=sortrows(tf_unique(idx,:),10);
    p = slope_idx(floor(L*bili):ceil(L*(1-bili)),:);
    P2=[P2;p];
    end
end
P1 = [];
for i = 1:length(ssc_rate_range)-1
    ssc_rate_min = ssc_rate_range(i);
    ssc_rate_max = ssc_rate_range(i+1);
    idx = find(ssc_rate_vec >= ssc_rate_min & ssc_rate_vec <= ssc_rate_max & ssc_vec > 50);
    L=length(idx);
    disp(L)
    if L<15
        continue
    else
    slope_idx=sortrows(tf_unique(idx,:),10);
    p = slope_idx(floor(L*bili):ceil(L*(1-bili)),:);
    P1=[P1;p];
    end
end
P=[P2;P1];
P(P(:,7)<20|P(:,7)>120,:)=[];
P(P(:,9)<-0.03|P(:,9)>0.03,:)=[];
P=sortrows(P,3);
P(:,end+1)=distance(P(:,3),P(:,2),P(32,3),P(32,2),6371393);
P=sortrows(P,12);
P(5:30,:)=sortrows(P(5:30,:),3,'descend');
P(31:34,:)=sortrows(P(31:34,:),2,'descend');
slope_plot=P;
x = P(:,7);
y = P(:,9);
c = P(:,10);
positive_c = c > 0;
negative_c = c < 0;
abs_c = abs(c);
min_size = 100;
max_size = 2000;
size_range = max_size - min_size;
s = min_size + size_range * ((abs_c-min(abs_c)) / (max(abs_c)-min(abs_c)));
s_1=min_size + size_range * ((0.01-min(abs_c)) / (max(abs_c)-min(abs_c)));
s_01=min_size + size_range * ((0.001-min(abs_c)) / (max(abs_c)-min(abs_c)));
min_size = 8;
max_size = 12;
size_range = max_size - min_size;
ts = min_size + size_range * ((abs_c-min(abs_c)) / (max(abs_c)-min(abs_c)));
p2=scatter(x(negative_c), y(negative_c), s(negative_c),'markeredgecolor',[1 1 1],'markerfacecolor', [78 171 144]/256,'MarkerFaceAlpha',0.7,'linewidth',1);
hold on;
p1=scatter(x(positive_c), y(positive_c), s(positive_c),'MarkerEdgeColor',[1 1 1],'markerfacecolor',[233 122 94]/256,'MarkerFaceAlpha',0.7,'linewidth',1);
[lgd,lg]=legend([p1 p2 p3],{'Expand','Retreat','Neutral zone'},'position',[0.2*700/xf (0.17*700-80)/yf 0.4*700/xf 0.1*700/yf],'Orientation','horizontal');
annotation('ellipse',[0.65 (0.175*700-80)/yf (s_1^0.5)/420*560/xf (s_1^0.5)/420*560/yf],'LineWidth',1,'Color','k','LineStyle','-.');
x_01=0.65+(s_1^0.5)/420*560/xf/2-(s_01^0.5)/420*560/xf/2;
annotation('ellipse',[x_01 (0.175*700-80)/yf (s_01^0.5)/420*560/xf (s_01^0.5)/420*560/yf],'LineWidth',1,'Color','k','LineStyle','-.');
xx_1=[0.65+(s_1^0.5)/420*560/xf/2+0.1 0.65+(s_1^0.5)/420*560/xf/2];yy_1=[(0.175*700-80)/yf+(s_1^0.5)/420*560/yf (0.175*700-80)/yf+(s_1^0.5)/420*560/yf];
annotation('textarrow',xx_1,yy_1,'String','1% ','HeadLength',4,'HeadWidth',4,'LineWidth',0.5)
xx_01=[0.65+(s_1^0.5)/420*560/xf/2+0.05 0.65+(s_1^0.5)/420*560/xf/2];yy_01=[(0.175*700-80)/yf+(s_01^0.5)/420*560/yf (0.175*700-80)/yf+(s_01^0.5)/420*560/yf];
annotation('textarrow',xx_01,yy_01,'String','0.1% ','HeadLength',4,'HeadWidth',4,'LineWidth',0.5)
lg(4).Children.MarkerSize = 12;
lg(5).Children.MarkerSize = 12;
lg(6).FaceAlpha=0.1;
lg(6).Vertices(1,2)=lg(6).Vertices(1,2)+0.2;
lg(6).Vertices(2,2)=lg(6).Vertices(2,2)-0.2;
lg(6).Vertices(3,2)=lg(6).Vertices(3,2)-0.2;
lg(6).Vertices(4,2)=lg(6).Vertices(4,2)+0.2;
legend('boxoff')
set(gca,'YTickLabel',num2str(get(gca,'YTick')'*100,'%g%%'))
set(gca,'FontSize',12,'fontname','times new roman');
set(h,'YTick',[-0.01 0 0.01 0.02 0.03],'fontsize',9)
set(h,'YTickLabel',num2str(get(h,'YTick')'*100,'%g%%'))
xlabel('current SSC (mg/L)','fontsize',15,'fontweight','bold')
ylabel('SSC change rate (year^{-1})','fontsize',15,'fontweight','bold')
xlim([20 120])
ylim([-0.03 0.03])
for i=1:length(x)
    text(x(i),y(i),num2str(i),'Color','black','FontSize',ts(i),'HorizontalAlignment','center','VerticalAlignment','middle')
end
%%
h1=axes('position',[0.72*700/xf (0.77*700-80)/yf 0.18*700/xf 0.18*700/yf]);	
axis(h1);	
World =shaperead('landareas.shp','UseGeoCoords',true);
ChinaL=shaperead('china1.shp');
ChinaP=shaperead('china2.shp');
hold on
geoshow(ChinaP,'facecolor',[.7 .7 .7],'edgecolor',[.8 .8 .8])
mapshow(ChinaL,'color',[.8 .8 .8])
scatter(slope_plot(positive_c,2),slope_plot(positive_c,3),20,[233 122 94]/256,'filled')
scatter(slope_plot(negative_c,2),slope_plot(negative_c,3),20,[78 171 144]/256,'filled')
x=[slope_plot(1,2) slope_plot(4,2)-1 slope_plot(5,2)-1 slope_plot(11,2)-2 slope_plot(12,2)-2.5 slope_plot(15,2)-2.5 slope_plot(20,2)-3 slope_plot(29,2)-2 slope_plot(32,2) slope_plot(34,2)-2];
y=[slope_plot(1,3)+1 slope_plot(4,3)+1 slope_plot(5,3)+1 slope_plot(11,3) slope_plot(12,3)  slope_plot(15,3) slope_plot(20,3) slope_plot(29,3)+1.5 slope_plot(32,3) slope_plot(34,3)+1];
text(x,y,{'1','4','5','11','12','15','20','29','32','34'},'Color',[.2 .2 .2],'FontSize',9,'fontname','times new roman')
xlim([104.7 128])
ylim([19.7 43])
yticks([])
xticks([])
set(gca,'color','none');
set(gca,'linewidth',0.5,'xcolor',[.8 .8 .8],'ycolor',[.8 .8 .8])
print('-djpeg','-r300','fig5.jpg')

参考文献:
Liu, S., Hu, Z., Grandjean, T.J.et al.Dynamics and drivers of tidal flat morphology in China.Nat Commun16, 2153 (2025). https://doi.org/10.1038/s41467-025-57525-y


网站公告

今日签到

点亮在社区的每一天
去签到