plotting multiple distributions on one graph

조회 수: 8 (최근 30일)
Kitt
Kitt 2024년 10월 8일
댓글: Star Strider 2024년 10월 8일
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!!
Star Strider
Star Strider 2024년 10월 8일
As always, my pleasure!

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

추가 답변 (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