When creating an app, how do you plot points on top of a line on a UI axis?

2 visualizaciones (últimos 30 días)
% We will write the following code in the button push function,
% since we want the push of this button to 1.)
main_axes = app.UIAxes;
weekval = app.WeekDropDown.Value;
drugval = app.DrugDropDown.Value;
temp_time = app.ecg_data.DATA.(weekval).(drugval).Time;
temp_ecg = app.ecg_data.DATA.(weekval).(drugval).ECG;
[peaksx, peaksy] = findpeaks(temp_ecg);
hold(main_axes, 'on' )
%This plots the line
plot(main_axes,temp_time,temp_ecg)
hold(main_axes, 'off' )
hold(main_axes, 'on' )
%This plots the points
plot(main_axes, peaksy,peaksx, '.');
hold(main_axes, 'off' )

Respuestas (2)

dpb
dpb el 2 de Mayo de 2023
% We will write the following code in the button push function,
% since we want the push of this button to 1.)
main_axes = app.UIAxes;
weekval = app.WeekDropDown.Value;
drugval = app.DrugDropDown.Value;
temp_time = app.ecg_data.DATA.(weekval).(drugval).Time;
temp_ecg = app.ecg_data.DATA.(weekval).(drugval).ECG;
[peaksx, peaksy] = findpeaks(temp_ecg);
%This plots the line
plot(main_axes,temp_time,temp_ecg)
hold(main_axes, 'on' )
%This plots the points
plot(main_axes, peaksy,peaksx, '*');
Don't reset hold until ready to draw a new figure/axes/plot...do that only at a beginning or if give user the option to clear the axes.
The above should have worked, likely just couldn't see the marker using just a '.' with no larger marker size than default.
The '*' should show up; salt to suit with color/size/marker/etc.,...

Image Analyst
Image Analyst el 2 de Mayo de 2023
Try xline or yline
% Get limits of axes
xl = xlim
yl = ylim
xine(xl(1), 'Color', 'r', 'LineWidth', 5) % Draw line along left edge of axes box.
xine(xl(2), 'Color', 'r', 'LineWidth', 5) % Draw line along right edge of axes box.
yine(yl(1), 'Color', 'r', 'LineWidth', 5) % Draw line along bottom edge of axes box.
yine(yl(2), 'Color', 'r', 'LineWidth', 5) % Draw line along top edge of axes box.

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by