Matlab散点图进阶——矩阵气泡图
作者:互联网
先上一个效果图
调用代码:
BubleMatric(["A" "B" "C" "D"], ["1" "2" "3" "4"], [7 5 1 3; 2 9 7 7; 3 4 9 2; 0 7 8 5], 250)
函数原型
[hfig, axes1] = BubleMatric(Xlabel, Ylabel, Zsize, PointSize)
函数源代码
function [hfig, axes1] = BubleMatric(Xlabel, Ylabel, Zsize, PointSize)
Zsize1 = Zsize;
Zsize1(Zsize==0) = 1E-9;
hfig = figure;
axes1 = axes('Parent',hfig);
set(axes1, 'YTick', 1:length(Ylabel), 'YTickLabel', Ylabel);
set(axes1, 'XTick', 1:length(Xlabel), 'XTickLabel', Xlabel);
col = length(Xlabel);
row = length(Ylabel);
hold on
axis([0 col+1 0 row+1])
for i = 1: row
scatter(1:col, ones(1,col)*i, Zsize1(i,:)*PointSize, 'filled');
for j = 1: col
if Zsize(i,j)>=1
text(j, i, num2str(Zsize(i,j),"%g"), ...
'HorizontalAlignment','center');
end
end
end
grid on
end
技术交流v:qczsbwjzjn
标签:Zsize,end,进阶,散点图,Xlabel,Matlab,Ylabel,axes1,col 来源: https://blog.csdn.net/qq_42276781/article/details/111290347