Plot prominences coming from findpeaks
Show older comments
Using this example, I can get a nice plot that contains the peaks and the prominences (and the widths too which I don't need):
findpeaks(X,'MinPeakProminence',0.05,'Annotate','extents')
However, I need the peaks and prominences plotted in a different plot that has different axes, other plots and better colors, so I plot them manually with a hold on as:
[pks,locs,~,p] = findpeaks(X,'MinPeakProminence',0.05,'Annotate','extents');
my_plot(X,time) %i have my own plotting function for this, which has a bunch of plot-beautifying stuff
hold on
scatter(time(locs),pks,20,'k','filled','v')
hold off
But I have no idea how to plot the prominences, since the prominence data p is a single number, I do not know where to start the line and where to finish it.
2 Comments
dpb
on 13 Jul 2022
'Pends on what you want the plot to be -- the 'annotate' option draws the prominence as the vertical line from the associated peak less the prominence value. That's it. For each peak, the y vector is [pk(i), pk(i)-p(i)]
The other thing the builtin plotting function does is to draw the horizontal line at pk(i)-p(i)/2 -- that's the one that you have to interpolate the signal to find the crossing on the x axis to the left/right of the peak location.
Answers (0)
Categories
Find more on Descriptive Statistics 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!