Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Português - 日本語 - Русский
Aide de Scilab >> Graphiques > Interactivité > locate


mouse selection of a set of points in a 2D axes


xy = locate()
xy = locate(n)
xy = locate(n, cross)




  • n > 0 : number of points to be selected.
  • any n ≤ 0 : undefined number of points. Stops the selection by right-clicking.
Default value = -1.


When cross it set to 1, locate(.) displays a "X" mark at each clicked position in the current axes. Default = 0.


matrix of size (2,n1). n1=n if the parameter n is given. xy(1,:) are abscissae. xy(2,:) are ordinates. xy(:,i) are the [x;y] coordinates of the ith clicked point.


locate is used to get the coordinates of one or more points selected with the mouse in the current graphic axes. The coordinates values use the data scales of the axes.

If n > 0, n points are expected to be selected. There is no way to escape the series before the nth point is clicked (except with CTRL+C). The coordinates of selected points are returned in the matrix xy.

If n ≤ 0, points are selected until the user clicks the right button of the mouse. The position of this exit click is neither recorded nor returned.

xy=locate() stands for xy=locate(-1).

Eventual crosses drawn when clicking are erased when locate() ends.

If the figure is closed (with its top-right cross) while locate() is running on it,

  • if n>0 : [] is returned.
  • if n <=0 : The coordinates of points already selected are returned.

Left clicking anywhere out of the current axes of the current figure does not select any point.
Logarithmic and/or reversed axes are supported.


x = 1:0.1:100;
plot2d("ll", x, 1.2 .^x)
xgrid(color("grey70")*[1 1], [1 1], [7 7]);
gca().axes_reverse(1) = "on";
gca().tight_limits = "on";
        gcf().axes_size=[600 320];
XY = locate(-1,1)  // Select any number of points. Right click to quit

// Draw a filled polygon made of the selected points
xfpolys(XY(1,:)',XY(2,:)', color("cyan"))
--> XY = locate(-1,1)
 XY  =
   40.22022    3.0199517   3.0199517   6.056507    10.102863   30.199517
   10082801.   9352311.2   94.100636   102608.45   1213.6949   95174.553

See also

  • edit_curv — éditeur graphique interactif
  • interactive editor — Interactive plot editor
  • rubberbox — rubberband box for rectangle selection
  • xclick — Attend une action d'un bouton de la souris, du clavier dans une fenêtre graphique.
  • ged — Scilab Graphic Editor
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Jul 20 11:19:20 CEST 2021