【matlab】地图上的小图

【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;close all;clc;
load nearshore_province.mat
table_tidalflat = readtable('China_tidalflat.csv','VariableNamingRule','preserve');
tidalflat = table2array(table_tidalflat);
load width_year.mat
load tsm_year.mat
nanloc1=find(isnan(tidalflat(:,6)));
tidalflat(nanloc1,:)=[];
tsm_10(nanloc1,:)=[];
tidalflat(:,9:10) = tidalflat(:,9:10)/100;
slope_bar=tidalflat;
%%
width_year=[width_2002 width_2005 width_2008 width_2011 width_2016];
width_mean=median(width_year,1,'omitnan');
x=2003:3:2015;
x1=700;
y1=700;
figure('Position', [10, 20, x1, y1],'color','w')
%%
[~,TF]=rmoutliers(tidalflat(:,10),'median');
rm=find(TF==1);
tidalflat(rm,:)=[];
[~,TF2]=rmoutliers(tidalflat(:,9),'median');
rm2=find(TF2==1);
tidalflat(rm2,:)=[];
[swh_uni,aa]=unique(tidalflat(:,7),'stable');
tf_unique=[];
for i=1:length(aa)
    loc=find(tidalflat(:,7)==swh_uni(i));
    slope_loc=tidalflat(loc,:);
    slope_u=mean(slope_loc,1);
    tf_unique=[tf_unique;slope_u];
end
tf_unique(isnan(tf_unique(:,10)),:)=[];
t1=length(find(tf_unique(:,10)<-0.025))/length(find(~isnan(tf_unique(:,10))));
t2=length(find(tf_unique(:,9)<0))/length(tf_unique(:,1));
ratio = sum(tf_unique(:,10).*tf_unique(:,9)>0)/sum(~isnan(tf_unique(:,10).*tf_unique(:,9)));
slope_diff = tf_unique(tf_unique(:,10).*tf_unique(:,9)>0,:);
World =shaperead('landareas.shp','UseGeoCoords',true);
ChinaL=shaperead('china1.shp');
ChinaP=shaperead('china2.shp');
hold on
geoshow(World,'facecolor',[.99 .99 .99],'edgecolor',[.3 .3 .3])
mapshow(ChinaL,'color',[.5 .5 .5])
mapshow(ChinaP(yanhai,:),'facecolor',[.7 .7 .7],'edgecolor',[.5 .5 .5])
mapshow(ChinaP(~yanhai,:),'facecolor',[.9 .9 .9],'edgecolor',[.9 .9 .9])
x = tf_unique(:,2); 
y = tf_unique(:,3); 
c = tf_unique(:,10); 
alpha = abs(c)./max(abs(c));
cmap = [2, 48, 74;19,103,131;33,158,188;144,201,231;233, 241, 244;251, ...
    227, 213;246,178,147;220,109,87;183,34,48; 109, 1, 31]/256;
n = size(cmap, 1);  
xq = linspace(1, n, 256);
cmap_smooth = interp1(1:n, cmap, xq, 'linear');
colormap(cmap_smooth);
scatter(x,y,7,c,'filled')%12
xlabel('Longitude (deg)','FontSize',8,'fontweight','bold');
ylabel('Latitude (deg)','FontSize',8,'fontweight','bold');
xticks([110 120])
xticklabels({'110°E','120°E'})
yticks([20 30 40])
yticklabels({'20°N','30°N','40°N'})
clim([-max(abs(c)), max(abs(c))]);
xlim([104 128])
ylim([17.5 41.5])
ax=gca;
ax.FontName = 'times new roman';
ax.FontSize = 8;
ax.TickLength = [0.01, 0.01];
ax.LineWidth = 1.5;
ax.XRuler.TickDirection = 'out';
ax.YRuler.TickDirection = 'out';
ax.Layer = 'top';
box on
% color bar site
h = colorbar('Location', 'south', 'Position', [.2, .5, 150/x1, 15/y1]);
ylabel(h,'Trend in annual Tidal flat width (%/year)','fontsize',8,'fontname','times new roman') 
set(h,'fontsize',8,'fontname','times new roman');
set(h,'YTickLabel',num2str(get(h,'YTick')'*100,'%g%%'))
% small figure 
xq1 = linspace(1, n, 15);
cmap_smooth1 = interp1(1:n, cmap, xq1, 'linear');
h1=axes('position',[.2, .55, 150/x1, 150/y1]);	% set the size of the small figure
edges=linspace(-0.07,0.07,15);
for i=1:length(edges)-1
histogram(tf_unique(:,10),edges(i:i+1), 'Normalization', 'probability','FaceColor',cmap_smooth1(i,:));
hold on
end
mu = mean(tf_unique(:,10));
sigma = std(tf_unique(:,10));
xx = min(tf_unique(:,10)):0.01:max(tf_unique(:,10));
yy = normpdf(xx, mu, sigma);
ax = gca;
counts = ax.YTick;
percentages = counts * 100;
ax.YTickLabel = string(percentages);
xlim([-0.08 0.08])
xticks([-0.05 0 0.05])
set(gca,'XTickLabel',num2str(get(gca,'XTick')'*100,'%g%%'))
ylabel('Frequency (%)','fontname','times new roman')
set(gca,'color','none');
box off
print('-djpeg','-r300','fig3.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

相关推荐
troy12817 分钟前
Python 基础语法(六):函数与模块、文件操作、异常处理
开发语言·python
lv__pf25 分钟前
09-深入理解AQS之独占锁ReentrantLock源码分析【TL 并发 09】
java·开发语言
这个DBA有点耶43 分钟前
数据库数据同步解决方案怎么选?6款主流工具横向对比与信创选型指南
数据库·架构·dba
这是程序猿1 小时前
Java线程池深度剖析:源码原理、核心参数、任务调度与生产调优实战
java·开发语言·python
刃神太酷啦1 小时前
Redis 核心进阶:哨兵、集群、缓存问题与分布式锁详解----《Hello Redis!》(6)
linux·c语言·数据库·c++·redis·分布式·缓存
小雷信息医学1 小时前
不会写复杂代码也能发 SCI?手把手教你用 InSpireR 交互系统一键提取、合并与导出临床科研宽表【第三章】
数据库
quantdash_cc1 小时前
从数据采集到策略消费,股票日内行情管道应该怎么设计?
开发语言·python·数据分析·量化交易·股票数据·quantdash
郝学胜-神的一滴1 小时前
C++20模板元编程 01:从零吃透模板核心底层逻辑
开发语言·c++·vscode·程序人生·开源
旺仔不是程序员1 小时前
复合索引最左前缀原则:PostgreSQL 的 WHERE 为什么必须命中第一列
数据库·后端·sql
旺仔不是程序员2 小时前
字段类型不一致:PostgreSQL 报错与索引失效的第一元凶
数据库·后端·sql