Problem in making multiple scatterplots/subplots?

3 visualizaciones (últimos 30 días)
IMC
IMC el 26 de Ag. de 2022
Comentada: IMC el 8 de Sept. de 2022
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.

Respuestas (1)

Abderrahim. B
Abderrahim. B el 26 de Ag. de 2022
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 comentario
IMC
IMC el 8 de Sept. de 2022
@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:

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by