Greetings, Anyway to help to create ridgeline by MATLAB
古いコメントを表示
Greetings,
Anyway to help to create ridgeline by MATLAB as the attache link please?
3 件のコメント
KALYAN ACHARJYA
2019 年 11 月 26 日
Which one, 1st or 2nd or 3rd figure?
Yaser Khojah
2019 年 11 月 26 日
採用された回答
その他の回答 (2 件)
Image Analyst
2019 年 11 月 28 日
Perhaps you'd be interested in stackedplot(): Pick of the Week

>> doc stackedplot
Introduced in R2018b.
Santiago Benito
2020 年 4 月 21 日
編集済み: Santiago Benito
2020 年 4 月 21 日
Hi there,
Maybe it's a little late, but I stumbled upon the same problem. I really wanted the plots to overlap, so I did the following:
% Number of data plots
n = 8;
% Sample points
N = 100;
% Distribution, example data
distName = 'normal';
mn = linspace(0,1,n);
% Allocate a matrix to store the dataset
yData = zeros(N,n);
% Plot options
mini = -0.3;
maxi = 1.3;
overlap = 0.4;
% Create the data
for ii = 1:n
distCell = makedist(distName,'mu',mn(ii),'sigma',0.1);
yData(:,ii) = pdf(distCell,linspace(mini,maxi,N));
end
% Get the position of each dataset
y = cumsum(max(yData,[],1))*(1-overlap);
% Create the figure with patch & plot
figure, hold on
for ii = n:-1:1
patch([linspace(mini,maxi,N),-mini],[yData(:,ii)+y(ii);y(ii)],mn(ii),...
'EdgeColor','none','FaceAlpha',0.8)
plot(linspace(mini,maxi,N),yData(:,ii)+y(ii),'k','LineWidth',1)
end
hold off
% Other stuff
colormap(spring)
yticks(y)
yticklabels({'A','B','C','D','E','F','G','H'})
xlim([mini,maxi])
The result:

Some thoughts:
- This is not as elegant as the other solutions, but works for me.
- You could add more information to the y-axis with some more coding.
Cheers!
6 件のコメント
Santiago Benito
2020 年 4 月 22 日
I couldn't help myself and quickly programmed a function that does just what I wanted.
It might be what you need: LINK

Cheers!
Image Analyst
2020 年 4 月 22 日
Looks like the built-in waterfall() function.
Santiago Benito
2020 年 4 月 23 日
waterfall() was the first thing I tried. But as far as I could tell, that works great for 3D representations. What I wanted to do is to plot a stack of 2D plots in a single axis. For instance, I don't think that waterfall can do something like this:

There you have 10 gamma distributions, their medians in the dashed vertical lines, the default colormap shows the local value of the probability density and the spring colormap shows the scale value of the each distribution. You can find this example and many others in the documentation of joyPlot.
Cheers!
Adam Danz
2020 年 4 月 23 日
Looks good, Santiago Benito. Tidy code, too.
Santiago Benito
2020 年 4 月 23 日
Thanks, Adam!
The colorbar in the example above is a bit confusing. There are two yellows that have different values. The lower colorbar should be based on something like the winter colormap which doesn't have intersecting colors with the spring colormap. It's not clear why 2 colormaps/colorbars are needed.
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



