Problem in making multiple scatterplots/subplots?

조회 수: 2 (최근 30일)
IMC
IMC 2022년 8월 26일
댓글: IMC 2022년 9월 8일
Hi everyone,
I am suppose to make 9 scatterplots/subplots in one figure/plot (separate is fine too). My data comprises of 4 variables named as G_temp, Aerosols (Aerosols Concentration), Volume and B_temp. I want to check the relationship between these 4 using scatterplots. What I tried to do for single scatterplot till now is:
Data=readtable('F:\My_Table\Data.xlsx', 'Sheet', 1, 'ReadVariableNames', true, 'VariableNamingRule','preserve');
N = 0:50:500; %
Data.Volume_Bin=discretize(Data.Volume,N);
figure
hAx=axes; hold on;
hL=splitapply(@plotrows,Data.Aerosols,Data.G_Temp,Data.Volume);
hAx.XScale='log'; grid on;
set(gca, 'YDir', 'reverse');
% plotrows function
function hL=plotrows(x,y,varargin)
xy=sortrows([x y]);
hL=scatter(xy(:,1),xy(:,2),varargin{:},'filled');
end
In the above code I checked relationship between three variables G_Temp, Aerosols and Volume. Also I want to make 3 bins of Volume (0-500, 500-900, 900-inf) and then plot it versus G_temp and Aerosols concentration. The above code is just for 1st bin (0-500) of volume and produces following scatterplot:
If I try to include the fourth variable.
N2 = 0:1:10
Data.BTemp = discretize(Data.B_Temp, N2);
hL=splitapply(@plotrows,Data.Aerosols,Data.G_Temp,Data.Volume, Data.BTemp);
Following is the result. This is for the first bin of volume and first bin of B_Temp.
Actually this is something which I am trying to make:
For the first bin of Energy and B_Temp, check relationship between G_temp and Aerosol conc. Moving to the next column, for the second bin of energy and first bin of B_Temp check relationship between G_temp and Aerosol conc, and so on.
I would really appreciate if someone can tell me how to do this. Thank you.
Data is attached.

답변 (1개)

Abderrahim. B
Abderrahim. B 2022년 8월 26일
Hi!
If my understanding is correct, there is a function called plotmatrix that comes with MATLAB and that I believe is more suitable for your case.
Below is a example on how to use ithe plotmatrix function.
dataTble = readtable('Data.xlsx', 'Sheet', 1, 'ReadVariableNames', true, 'VariableNamingRule','preserve');
varNames = string(dataTble.Properties.VariableNames);
% plotmatrix only accepts matrix as input argument
Data = table2array(dataTble) ;
[S,AX,BigAx,H,HAx] = plotmatrix(Data,Data ) ;
for ii = 1:4
AX(4,ii).XLabel.String = varNames(1,ii) ;
AX(ii,1).YLabel.String = varNames(1,ii) ;
S(ii,ii).Color = 'k' ; % this is just to highlight a variable when compared to itself.
end
Note that you still can improve the readability of this plot, for instance changing the color each each axes ..
Hope this helps
  댓글 수: 1
IMC
IMC 2022년 9월 8일
@Issa Thank you for your answer.
Here you've plotted is 4 variables against 4 variables. I don't want it like this.
What I want is that for the first bin of Energy (0-500) and B_Temp (0-10), check relationship between G_temp and Aerosol conc. Moving to the next column, for the second bin of energy (500-900) and first bin of B_Temp (0-10) check relationship between G_temp and Aerosol conc, and so on.
Like this figure:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by