plotting multiple distributions on one graph

8 Ansichten (letzte 30 Tage)
Kitt
Kitt am 8 Okt. 2024
Kommentiert: Star Strider am 8 Okt. 2024
What I'm wanting is a little complicated.
I have an matrix, simphystate, that is (20x1000), or 20 timesteps x 1000 individuals, and the elements can range from 1 to 15
I want to plot the distribution of simphystate over each timestep, but I want to exclude points where the element of an individual at any given timestep is 1 (these individuals are dead)
plotting a histogram with so many distributions just blurs together, so I was thinking I could just plot the line representing the distribution. Something that would look like this :
is this possible?

Akzeptierte Antwort

Star Strider
Star Strider am 8 Okt. 2024
I am not certain what your data are, so I will create some.
A = randn(20, 1000);
A = (A - min(A,[],2)) + 1;
A = A .* 15./max(A,[],2) + randi(9, 20, 1);
for k = 1:size(A,1)
pd{k} = fitdist(A(k,:).', 'normal');
end
x = linspace(1, 30, 150);
figure
hold on
for k = 1:size(A,1)
plot(x, pdf(pd{k},x), "DisplayName","Row "+k)
end
grid
legend('Location','best')
You could also use plot3 for this, and separate the individual distributions by row number.
.
  2 Kommentare
Kitt
Kitt am 8 Okt. 2024
I actually ended up using boxplots as suggested by a peer and just replaced the numbers I didn't want with NaN which worked. But thank you for much for your answer and support!!
Star Strider
Star Strider am 8 Okt. 2024
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by