You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to change the colour or text or delete some text of the default graph in findpeaks function?
2 views (last 30 days)
Show older comments
How to change the colour or text or delete some text of the default graph in findpeaks function?
In this code below from matlab link https://ch.mathworks.com/help/signal/ref/findpeaks.html

It used "findpeaks"
% generate data
x = linspace(0,1,1000);
base = 4*cos(2*pi*x);
Pos = [1 2 3 5 7 8]/10;
Hgt = [3 7 5 5 4 5];
Wdt = [1 3 3 4 2 3]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss)+base;
% findpeaks function
findpeaks(PeakSig,x,'MinPeakProminence',4,'Annotate','extents')
9 Comments
Matlaber
on 16 Feb 2020
Thanks. I able to see:
However, I can I like delete/edit or change some of the displayname?
AlignVertexCenters: 'off'
Annotation: [1×1 matlab.graphics.eventdata.Annotation]
BeingDeleted: 'off'
BusyAction: 'queue'
ButtonDownFcn: ''
Children: [0×0 GraphicsPlaceholder]
Clipping: 'on'
Color: [0.9290 0.6940 0.1250]
CreateFcn: ''
DeleteFcn: ''
DisplayName: 'width (half-prominence)'
HandleVisibility: 'on'
HitTest: 'on'
Interruptible: 'on'
LineJoin: 'round'
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerEdgeColor: 'auto'
MarkerFaceColor: 'none'
MarkerIndices: [1 2 3 4 5 6]
MarkerSize: 6
Parent: [1×1 Axes]
PickableParts: 'visible'
Selected: 'off'
SelectionHighlight: 'on'
Tag: 'HalfProminenceWidth'
Type: 'line'
UIContextMenu: [0×0 GraphicsPlaceholder]
UserData: []
Visible: 'on'
XData: [0.1759 0.2190 NaN 0.4687 0.5313 NaN]
YData: [5.4652 5.4652 NaN -1.2093 -1.2093 NaN]
ZData: [1×0 double]
Answers (1)
Muhammad Usama Sharaf SAAFI
on 16 Feb 2020
use
title('');
command to change text after findpeak() function,
use
whitebg('blue');
to change color.
9 Comments
Matlaber
on 16 Feb 2020
Sorry, is not changing the title of graph.
I mean changing the "box display" (As i circle in red colour).
i think is change inside the function findpeaks.m
Muhammad Usama Sharaf SAAFI
on 16 Feb 2020
I got your point. just use
legend('abc');
after findpeak() function it will work.
Thanks
Muhammad Usama Sharaf SAAFI
on 16 Feb 2020
legend('abc','xyz','123');
replace "abc" "xyz" "123" with your msg.
Muhammad Usama Sharaf SAAFI
on 16 Feb 2020
Edited: Muhammad Usama Sharaf SAAFI
on 16 Feb 2020
Use '--b' parameter in findpeak(....,'--b') function. You can use '--r' for red color
Matlaber
on 17 Feb 2020
Not sure what I am doing is correct.
>> findpeaks(PeakSig,x,'MinPeakProminence',4,'Annotate','extents','--b')
Error using findpeaks>parse_inputs (line 288)
No value was given for '--b'. Name-value pair arguments require a
name followed by a value.
Error in findpeaks (line 136)
= parse_inputs(isInMATLAB,Yin,varargin{:});
Muhammad Usama Sharaf SAAFI
on 17 Feb 2020
findpeaks(PeakSig,x,'MinPeakProminence',4,'Annotate','extents');
legend({'xyz','abc'},'FontSize',12,'TextColor','green');
use this command it will works perfect for you.
Thanks
Matlaber
on 17 Feb 2020
Thanks for your reply.
I would like to change the colour of the line, and not the colour of the text color as shown below in circle.

See Also
Categories
Find more on Discrete Data 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!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)