虽然网上已经有很多台风路径的画法
但是大多数都是比较基本的路径画法
这篇博文提供一个融合画法,稍微高级一丢丢
包括配色选择、字体选择等
有些内容是参考了别人的内容,但是现在也想不起来是哪里参考的了
非常感谢各位的支持,和无数无私的知识分享者的帮助
直接上图,选择的台风案例是著名的2015年9号台风灿鸿,
该台风生命周期覆盖了所有台风强度,持续时间长,经过中国东海
具有一定代表性
绘图基本思路:
1、路径根据台风强度改变颜色,深色代表强度高。
2、部分留白,用于标注台风名称
3、更换海洋、陆地配色
4、Legend需要在地图外绘制线条然后隐藏起来,并使用这个线条的句柄
代码:
%% 读取数据
clear
clc
% 台风数据
Typhoon = readtable("typhoon.xlsx",'VariableNamingRule','preserve');% 用preserve就可以保存列名
% 提取台风路径数据
position = Typhoon(:,["lon","lat"]);
% 台风等级划分依据
class = [8,9;
10,11;
12,13;
14,15;
16,17];
% 时区转化并提取时间数据
date = datetime(table2cell(Typhoon(:,"Time")))-hours(8);% 北京时间-8h = UTC
% 颜色RGB数据
CR = [0.431372549019608 0.862745098039216 0.976470588235294
0.988235294117647 0.882352941176471 0.368627450980392
0.913725490196078 0.800000000000000 0.831372549019608
0.992156862745098 0.0156862745098039 0.0352941176470588
0.278431372549020 0.0941176470588235 0.223529411764706];
%% 绘图
figure;
% 生成m_map的project
m_proj('Equidistant Cylindrical','long',[110 160],'lat',[5 45]);
% 海岸线
m_gshhs_i('patch',[237 239 218]/255);% 高精度
% m_coast('patch',[237 239 218]/255);% 低精度
% 边框
m_grid('box','on','tickdir','in','backcolor',[151/255 183/255 224/255],'linewidth',2,'fontsize',14);
% 指北针
m_northarrow(134,40,4,'type',3);
% 将坐标和强度储存至临时变量里
current = table2array(position);
current = [current,table2array(Typhoon(:,"intensity"))];
% 用于绘图的data, 1lon 2lat 3强度 4等级
% 此步将根据强度划分等级
for i=1:length(current)
[data(i,1),data(i,2)]=m_ll2xy(current(i,1),current(i,2));
data(i,3)=current(i,3);
for j=1:5
if data(i,3)==class(j,1)||data(i,3)==class(j,2)
data(i,4)=j;
end
end
end
hold on
% 思路:添加图例