Hide peaks ticks and number on plots

1 view (last 30 days)
Luca de Freitas
Luca de Freitas on 6 Aug 2021
Commented: Star Strider on 6 Aug 2021
Hi all,
I am trying to hide the text above some peaks in the following plot. I would need to display only the following peaks:
3,4
7,8,9,10,11,12,13,14,15,16,17,18,19,20
(as highlighted in the figure)
Here is the plot:
The code I used to produce the plot is the following:
load('pO2,Mean,Numeric,Float,Raumedic,data_part1of1.mat');
ox = measurement_data;
smooth_ox = smooth(ox, 0.01, 'loess');
%find peaks
[pks,locs,wdths] = findpeaks(smooth_ox,'MinPeakProminence',0.5);
locmax = islocalmax(smooth_ox);
figure()
findpeaks(smooth_ox,'MinPeakProminence',0.5);
text(locs+.02,pks,num2str((1:numel(pks))'))
title('Peaks')
ylim([25 70]);
Thank youin advance for the help!

Answers (2)

KSSV
KSSV on 6 Aug 2021
Try:
load('pO2,Mean,Numeric,Float,Raumedic,data_part1of1.mat');
ox = measurement_data;
smooth_ox = smooth(ox, 0.01, 'loess');
%find peaks
% [pks,locs,wdths] = findpeaks(smooth_ox,'MinPeakProminence',0.5);
% locmax = islocalmax(smooth_ox);
figure()
findpeaks(smooth_ox,'MinPeakProminence',0.5);
% text(locs+.02,pks,num2str((1:numel(pks))'))
title('Peaks')
ylim([25 70]);
  2 Comments
KSSV
KSSV on 6 Aug 2021
You can get location indieces of the peaks, pick only those which you want to display and annotate or mark them.

Sign in to comment.


Star Strider
Star Strider on 6 Aug 2021
There is likely no way to select only those peaks, since there does not appear to be anything that distinguishes them, unless that information is in the original data.
So, just subscript them and be done with it:
selpks = [3,4, 7:numel(pks)];
text(locs(selpks)+.02,pks(selpks),num2str((1:numel(pks))'))
.
  2 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!