Greetings, Anyway to help to create ridgeline by MATLAB
Ältere Kommentare anzeigen
Greetings,
Anyway to help to create ridgeline by MATLAB as the attache link please?
3 Kommentare
KALYAN ACHARJYA
am 26 Nov. 2019
Which one, 1st or 2nd or 3rd figure?
Yaser Khojah
am 26 Nov. 2019
Akzeptierte Antwort
Weitere Antworten (2)
Image Analyst
am 28 Nov. 2019
Perhaps you'd be interested in stackedplot(): Pick of the Week

>> doc stackedplot
Introduced in R2018b.
Santiago Benito
am 21 Apr. 2020
Bearbeitet: Santiago Benito
am 21 Apr. 2020
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 Kommentare
Santiago Benito
am 22 Apr. 2020
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
am 22 Apr. 2020
Looks like the built-in waterfall() function.
Santiago Benito
am 23 Apr. 2020
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
am 23 Apr. 2020
Looks good, Santiago Benito. Tidy code, too.
Santiago Benito
am 23 Apr. 2020
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.
Kategorien
Mehr zu Color and Styling finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



