Updating the histogram in a correlation matrix after creating the matrix plot

3 visualizzazioni (ultimi 30 giorni)
I have this code which makes a correlation matrix. I want to create the matrix plot as below and later I want to update the histogram with different sets. Any idea please?
% your example code
Fields = [1, 4, 5];
Fields_time = Fields +16;
MT_All = rand(100,26);
% MT_All = rand(100,9);
VariableNames={'sigma','sigma','sigma','tau','tau','tau','mNPV'}; % changed to ensure valid syntax
Mat_All_1_4_5 = [MT_All(:,Fields), MT_All(:,Fields_time), MT_All(:,end-1)];
figure
c = corrplot(Mat_All_1_4_5, 'varNames', VariableNames);
% get current figure handle
fh = gcf;
% find x and y label strings that are not empty within subplots
yLabelN = find(cell2mat(arrayfun(@(dIn)~isempty(dIn.YLabel.String),fh.Children,'UniformOutput',false)));
xLabelN = find(cell2mat(arrayfun(@(dIn)~isempty(dIn.XLabel.String),fh.Children,'UniformOutput',false)));
% rename y labels
for ik = 1:length(yLabelN)
if ik <= 3
fh.Children(yLabelN(ik)).YLabel.String = sprintf('\\sigma_{%d}',Fields(ik));
fh.Children(xLabelN(ik)).XLabel.String = sprintf('\\sigma_{%d}',Fields(ik));
elseif ik <=6
fh.Children(yLabelN(ik)).YLabel.String = sprintf('\\tau_{%d}',Fields(ik-3));
fh.Children(xLabelN(ik)).XLabel.String = sprintf('\\tau_{%d}',Fields(ik-3));
else
fh.Children(yLabelN(ik)).YLabel.String = sprintf('m_{NPV}');
fh.Children(xLabelN(ik)).XLabel.String = sprintf('m_{NPV}');
end
end

Risposta accettata

Mehmed Saad
Mehmed Saad il 11 Mag 2020
[r,p,h] = corrplot(Mat_All_1_4_5, 'varNames', VariableNames);% change here pass handle output
h contains handles to plotted graphic object
type h in command window
h
You will see
h =
7×7 graphics array:
Histogram Line Line Line Line Line Line
Line Histogram Line Line Line Line Line
Line Line Histogram Line Line Line Line
Line Line Line Histogram Line Line Line
Line Line Line Line Histogram Line Line
Line Line Line Line Line Histogram Line
Line Line Line Line Line Line Histogram
Now all the diagonal elements are histogram
either generate logical diagonal matrix and index it or use subs (1,1) (2,2) (3,3),... (7,7)
For example
h(2,2).Data = rand(100,1)

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by