plotting multiple distributions on one graph
15 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Star Strider
on 8 Oct 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 Comments
More Answers (0)
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!