Matlab - 一种更好的插值散点热图的方法
Matlab - A Better Way to Interpolate for a Scatter Heatmap
我正在 MATLAB 中为我的选择性数据插值散点热图。下面的代码是关于随机数据的。但是,我的数据清楚地显示 "well-defined distinct squares," 使其看起来非常不稳定。寻找更好和改进的方法来插值散点图或更好的另一种创建散点图的新方法?
这是我的代码:
xd = randn(100000,1)';
yd = randn(100000,1)';
n = 100;
xi = linspace(min(xd(:)),max(xd(:)),n);
yi = linspace(min(yd(:)),max(yd(:)),n);
xr = interp1(xi,1:numel(xi),xd,'nearest')';
yr = interp1(yi,1:numel(yi),yd,'nearest')';
z = accumarray([xr yr], 1, [n n]);
figure;
imagesc(z)
j = jet
j(1,:) = [ 1 1 1 ]; %
colormap(j);
colorbar;
你应该可以通过使用pcolor
而不是imagesc
获得更平滑的热图,然后将着色模式设置为"interpolated",调用命令shading interp
.
我正在 MATLAB 中为我的选择性数据插值散点热图。下面的代码是关于随机数据的。但是,我的数据清楚地显示 "well-defined distinct squares," 使其看起来非常不稳定。寻找更好和改进的方法来插值散点图或更好的另一种创建散点图的新方法?
这是我的代码:
xd = randn(100000,1)';
yd = randn(100000,1)';
n = 100;
xi = linspace(min(xd(:)),max(xd(:)),n);
yi = linspace(min(yd(:)),max(yd(:)),n);
xr = interp1(xi,1:numel(xi),xd,'nearest')';
yr = interp1(yi,1:numel(yi),yd,'nearest')';
z = accumarray([xr yr], 1, [n n]);
figure;
imagesc(z)
j = jet
j(1,:) = [ 1 1 1 ]; %
colormap(j);
colorbar;
你应该可以通过使用pcolor
而不是imagesc
获得更平滑的热图,然后将着色模式设置为"interpolated",调用命令shading interp
.