Setting and saving markers on plots
3 views (last 30 days)
Show older comments
I have a plot in a GUI window. I would like to set markers to signify the beginning and end in a peak on the plot. I know that it is possible to set a marker from this question on Mathworks: https://uk.mathworks.com/matlabcentral/answers/119402-how-to-set-a-marker-at-one-specific-point-on-a-plot-look-at-the-picture
I need to know if it is possible to set multiple marks, one for the beginning and end points of a peak. As well as this, there may be more than one peak in my plot and these peaks too will need to be marked so that the area under each curve can be calculated. Is this possible using the method in the question above? Is it possible to then save the spatial location of these markers so that they can be placed onto other plots?
1 Comment
dpb
on 30 May 2017
Well, the answer is "yes" but there are multiple possible ways/objectives outlined in the answers to the above question. Which do you have in mind?
Answers (1)
dpb
on 30 May 2017
You might look at the code in Answer to a slightly different question just the other day where I drew a plot that does something like you're asking...so I'll just duplicate the pertinent section here and if the crystal ball happens to be working, then...
>> load mtlb % a sample dataset
>> select = mtlb(1001:1200); % and tiny subset therefrom
>> x=1:length(select); % corollary x variable
>> [pks,locs,wdths]=findpeaks(select,1:length(select),'MinPeakHeight',2); % analyze
>> plot(x,select) % plot
>> hold on
>> hL=plot(locs,pks,'r*'); % mark the peak locations
>> pk1=[locs(1)-fix(wdths(1)):locs(1)+ceil(wdths(1))]; % set the range for the first peak
>> plot(x(pk1),select(pk1),'r-') % and highlight it
>>
Above yields
The section that finds/marks the first FWHM peak area can be easily automated for all the rest as well; I just used the first subscript for example...
2 Comments
dpb
on 31 May 2017
Well, that was part of the question...you may want to look at
doc ginput
for user interaction instead of totally automated annotation.
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!