【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

相关推荐
Evand J4 分钟前
【MATLAB例程】AOA定位、AOA与TOA混合定位,二维环境下的对比,基站(锚点数量)自适应调整,附代码下载链接
开发语言·matlab
愚公搬代码14 分钟前
【愚公系列】《Python网络爬虫从入门到精通》055-Scrapy_Redis分布式爬虫(安装Redis数据库)
数据库·爬虫·python
Thomas_YXQ15 分钟前
Unity3D ILRuntime与Scripting Backend整合指南
服务器·开发语言·unity·unity3d
Chandler2418 分钟前
Go:反射
开发语言·后端·golang
pwzs25 分钟前
深入浅出 MVCC:MySQL 并发背后的多版本世界
数据库·后端·mysql
盒子691025 分钟前
go for 闭环问题【踩坑记录】
开发语言·后端·golang
加点油。。。。27 分钟前
C语言高频面试题——strcpy与memcpy区别
c语言·开发语言
大熊猫今天吃什么41 分钟前
【一天一坑】空数组,使用 allMatch 默认返回true
前端·数据库
拓端研究室TRL1 小时前
Python+AI提示词比特币数据预测:Logistic逻辑回归、SVC及XGB特征工程优化实践
开发语言·人工智能·python·算法·逻辑回归
双叶8361 小时前
(51单片机)LCD显示数据存储(DS1302时钟模块教学)(LCD1602教程)(独立按键教程)(延时函数教程)(I2C总线认识)(AT24C02认识)
c语言·数据库·单片机·嵌入式硬件·mongodb·51单片机·nosql