6

如何去掉 ginput 的十字架

 3 years ago
source link: https://zhiqiang.org/coding/remove-cross-of-ginput-in-matlab.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何去掉 ginput 的十字架

作者: 张志强

, 发表于 2011-05-27

, 共 380 字 , 共阅读 162 次

读者来信:

想问你一个关于 Matlab 的问题,我画了函数的图像,然后想用鼠标取点坐标,我用了 ginput ,但是总会出现一个黑色十字架,怎样把那个十字架消除掉?或者可以用其他命令的?我只想用鼠标取点坐标值,不想在图像上有任何痕迹。

回答(对应 2010b 版 Matlab ,版本不一样的话方法可能略有差别。):

修改 ginput 的源文件,将其中的

set(fig,'pointer','fullcrosshair');
修改为

set(fig, 'pointer', 'circle');
其中'circle'可以修改为任何想要的形状,比如'hand'表示手型鼠标,具体可查看内置的可用形状

如果不想直接改动源文件的话,可以将上述 ginput 复制到一个新函数,比如 ginput1。然后按照需要调用 ginput 或 ginput1。

Q. E. D.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK