主要函数为 bubblechart()
该函数是在 R2020b 中推出的,因此作图需要 MATLAB R2020b 或更新的版本
首先贴一下效果图,这副图中,气泡大小表示份额,气泡颜色表示总量
然后贴一下代码
%%首先读取 datae2007 和 datae2007_,即两组r×c的数组,前者表示份额,后者表示总量
datae2007 = xlsread(filepath,"e2007");
datae2007_ = xlsread(filepath1,"e2007");
% 生成矩阵坐标数据
[r,c] = size(datae2001);
x = 1:c;
y = 1:r;
[xx,yy] = meshgrid(x,y);
%yy = flipud(yy);
ax2 = nexttile;
bubblechart(xx(:),yy(:),datae2007(:),datae2007_(:),'MarkerFaceAlpha',1);
hTitle = title('2007');
hXLabel = xlabel('横坐标标题');
hYLabel = ylabel('纵坐标标题');
% 调节气泡大小
bubblesize([1 18])
% 坐标轴美化
axis equal
set(gca, 'Box', 'on', .