matlab
复制代码
clc
clear
close all
%% 读取数据
load('MyColor.mat') %读取颜色包
for iloop = 1:25 %提取工作表数据
data0(iloop) = {readtable('data.xlsx','sheet',iloop)};
end
%% 解析数据
count=zeros(23,14);
for iloop = 1:25
index(iloop) ={ cell2mat(table2array(data0{1,iloop}(1,1)))};
data(iloop) = { flipud(data0{1,iloop}(2:end,2:end))};
count = count+table2array( flipud(data0{1,iloop}(2:end,2:end)));
end
country = flip(table2array(data0{1,1}(2:end,1))); %提取国家名称
year = table2array(data0{1,1}(1,2:end)); %提取年份名称
%% 画分网格
x_lim = [0.5:14.5];
y_lim = [0.5:23.5];
%% 绘图
figure('Position',[50 50 1000 1000]) %设置figure
ax1=axes('Position',[0.72 0.100 0.2 0.6],...
'XAxisLocation','bottom','YAxisLocation','left','Color','none','XColor','k','YColor','k','XTick',[],'YTick',[]); %上图坐标区
ax2=axes('Position',[0.12 0.7 0.6 0.2],...
'XAxisLocation','bottom','YAxisLocation','left','Color','none','XColor','k','YColor','k','XTick',[],'YTick',[]); %右图坐标区
ax3=axes('Position',[0.12,0.1,0.6,0.6],'XColor','k','YColor','k');%主图坐标区
%% 坐标轴1
% 绘制网格
for iloop = 1:length(y_lim)
h=yline(y_lim(iloop),'-');hold on
h.Alpha=0.4;
end
for iloop = 1:length(x_lim)
h=xline(x_lim(iloop),'-');hold on;
h.Alpha=0.4;
end
% 绘制点
for jloop=1:14
for iloop=1:23
x_random(iloop,jloop)={ randany( x_lim(jloop), x_lim(jloop+1), count(iloop,jloop) )};
y_random(iloop,jloop)={ randany( y_lim(iloop), y_lim(iloop+1), count(iloop,jloop) )};
end
end
在这里插入代码片