plotting multiple distributions on one graph

15 次查看(过去 30 天)
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?

采纳的回答

Star Strider
Star Strider 2024-10-8
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 个评论
Kitt
Kitt 2024-10-8
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!!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by