简体   繁体   English

如何在Matlab轴上绘制多个单击的点?

[英]How to plot multiple clicked points on a Matlab axes?

Using ginput (or ginputax ) I ask my user to click on an axes 10 times (for spectrum baseline correction). 使用ginput (或ginputax ),我要求用户单击轴10次(用于频谱基线校正)。

My axes is based on a GUIDE GUI. 我的轴基于GUIDE GUI。

Essentially this begins like this 本质上,这是这样开始的

plot(handles.axes_preview, ppm, xf_base, 'w-', 'LineWidth', 2);

spline_ppm = ginputax(handles.axes_preview, 10);

I'd like to plot each click (as ro ) as they're being input , so the user has some feedback of where they clicked. 我想在输入时绘制每次点击(as ro ),以便用户对他们点击的位置有一些反馈。

Any ideas how to code this? 任何想法如何编写此代码?

How about a simple loop? 一个简单的循环怎么样?

axis(handles.axes_preview); %// make handles.axes_preview the current axis
hold on
for ii = 1:10
    coords(ii,:) = ginput(1);
    plot(coords(ii,1),coords(ii,2),'ro')
end

Also, you may want to add 另外,您可能要添加

set(handles.axes_preview),'XLimMode','manual');
set(handles.axes_preview),'YLimMode','manual');

at the beginning to prevent the axis scale from automatically changing as points are input by the user. 刚开始时防止轴刻度随着用户输入点而自动更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM