MATLAB中的奇异相关图

MATLAB中的奇异相关图,matlab,plot,correlation,Matlab,Plot,Correlation,我试图找到一种方法,在MATLAB中生成这些漂亮的相关图。这些是在R中使用“corrplot”函数生成的,但在MATLAB中找不到任何类似的代码。任何帮助都将不胜感激 作为快速描述,此函数将创建相关值的颜色比例,并在相关矩阵/绘图的每个单元格中创建具有关联颜色的圆圈。圆圈的大小也是相关性大小的指标,较大的圆圈表示较强的关系(正或负)。可以找到更多细节 您可以使用(或修改它,取决于您在matlab中的表达方式),以获得相关矩阵的类似可视化效果(上图)。或者使用,看起来也有点类似(下图) 我可

我试图找到一种方法,在MATLAB中生成这些漂亮的相关图。这些是在R中使用“corrplot”函数生成的,但在MATLAB中找不到任何类似的代码。任何帮助都将不胜感激

作为快速描述,此函数将创建相关值的颜色比例,并在相关矩阵/绘图的每个单元格中创建具有关联颜色的圆圈。圆圈的大小也是相关性大小的指标,较大的圆圈表示较强的关系(正或负)。可以找到更多细节

您可以使用(或修改它,取决于您在matlab中的表达方式),以获得相关矩阵的类似可视化效果(上图)。或者使用,看起来也有点类似(下图)


我可以根据提供的代码编写以下代码来生成类似的图形

此处提供了精确的图表:

我想您最好为绘图编写一个
.R
脚本,并从MATLAB调用它
% Produce the input lower triangular matrix data
C = -1 + 2.*rand(12,12);
C = tril(C,-1);
C(logical(eye(size(C)))) = 1;
% Set [min,max] value of C to scale colors
clrLim = [-1,1];
% load('CorrColormap.mat') % Uncomment for custom CorrColormap
% Set the  [min,max] of diameter where 1 consumes entire grid square
diamLim = [0.1, 1];
myLabel = {'ICA','Elev','Pr','Rmax','Rmin','Srad','Wspd','Tmin','Tmax','VPD','ET_o','AW'};
% Compute center of each circle
% This assumes the x and y values were not entered in imagesc()
x = 1 : 1 : size(C,2); % x edges
y = 1 : 1 : size(C,1); % y edges
[xAll, yAll] = meshgrid(x,y);
xAll(C==0)=nan; % eliminate cordinates for zero correlations
% Set color of each rectangle
% Set color scale
cmap = jet(256);
% cmap = CorrColormap; % Uncomment for CorrColormap
Cscaled = (C - clrLim(1))/range(clrLim); % always [0:1]
colIdx = discretize(Cscaled,linspace(0,1,size(cmap,1)));
% Set size of each circle
% Scale the size between [0 1]
Cscaled = (abs(C) - 0)/1;
diamSize = Cscaled * range(diamLim) + diamLim(1);
% Create figure
fh = figure();
ax = axes(fh);
hold(ax,'on')
colormap(ax,'jet');
% colormap(CorrColormap) %Uncomment for CorrColormap
tickvalues = 1:length(C);
x = zeros(size(tickvalues));
text(x, tickvalues, myLabel, 'HorizontalAlignment', 'right');
x(:) = length(C)+1;
text(tickvalues, x, myLabel, 'HorizontalAlignment', 'right','Rotation',90);
% Create circles
theta = linspace(0,2*pi,50); % the smaller, the less memory req'd.
h = arrayfun(@(i)fill(diamSize(i)/2 * cos(theta) + xAll(i), ...
    diamSize(i)/2 * sin(theta) + yAll(i), cmap(colIdx(i),:),'LineStyle','none'),1:numel(xAll));
axis(ax,'equal')
axis(ax,'tight')
set(ax,'YDir','Reverse')
colorbar()
caxis(clrLim);
axis off