File Exchange

image thumbnail

GINPUT FOR UIAXES

version 1.0.0 (2.29 KB) by Toey
GINPUTUIAX is similar to Matlab's original GINPUT, except that it works with UIFIGURE & UIAXES

12 Downloads

Updated 02 Jul 2020

View License

%GINPUTUIAX Graphical input from mouse with custum cursor pointer.
% [X,Y] = ginputuiax(huiax,N) gets N points from the uiaxes, huiax and returns
% the X- and Y-coordinates in length N vectors X and Y.
% GINPUTUIAX is similar to Matlab's original GINPUT, except
% that it works with UIFIGURE & UIAXES
% Example:
% ax=uiaxes; plot(ax,rand(1,100))
% [x,y] = ginputuiax(ax,2)
%
% Adapted from GINPUTC by Jiro Doke
% Wanwara Thuptimdang
% Date: 1July2020

Cite As

Toey (2021). GINPUT FOR UIAXES (https://www.mathworks.com/matlabcentral/fileexchange/77605-ginput-for-uiaxes), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Lea Corbova

Jim Sculley

Why does this tool perform so poorly when the axis style is set to 'equal'? With this simple example, it is like dragging the crosshairs through molasses:
f=uifigure;
ax=uiaxes(f);
axis(ax,'equal');
plot(ax,rand(100,1));
[x,y]=ginputuiax(ax, 1);

Patrik Procka

Thank you for your script. It help me to write appropriate scrip for my use.

Jana Pecke

or I only have a "large" black square as cursor when using it in the App Designer. Can you change that?

Jana Pecke

is it possible to make the pointer square smaller or to exchange it for an empty circle?

Toey

This function works with matlab2020. Matlab doesn't allow us to set uifigure property in the previous versions.
I forgot to mention that.

Chang hsiung

I got the following errors while running your example ?
>> ax=uiaxes; plot(ax,rand(1,100))
>> [x,y] = ginputuiax(ax,2)
Error using matlab.ui.Figure/set
Functionality not supported with figures created with the uifigure function. For more
information, see Graphics Support in App Designer.

Error in ginputuiax (line 38)
set(hFig, ...

No appropriate method, property, or field 'CurrentPoint' for class
'matlab.ui.control.UIAxes'.

Error in ginputuiax/mouseMoveFcn (line 56)
cursorPt = huiax.CurrentPoint;

Error using matlab.ui.internal.controller.FigureController/handleEvent (line 300)
Error while evaluating Figure WindowButtonMotionFcn.

No appropriate method, property, or field 'CurrentPoint' for class
'matlab.ui.control.UIAxes'.

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Custom GINPUT

Community Treasure Hunt

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

Start Hunting!