GNU Octave: Interacting with Plots

Next: Test Plotting Functions, Previous: Printing and Saving Plots, Up: High-Level Plotting [Contents][Index]

#### 15.2.10 Interacting with Plots

The user can select points on a plot with the `ginput` function or selection the position at which to place text on the plot with the `gtext` function using the mouse. Menus may also be created and populated with specific user commands via the `uimenu` function.

Function File: [x, y, buttons] = ginput (n)
Function File: [x, y, buttons] = ginput ()

  Return the position and type of mouse button clicks and/or key strokes in the current figure window.

  If n is defined, then capture n events before returning. When n is not defined `ginput` will loop until the return key `RET` is pressed.

  The return values x, y are the coordinates where the mouse was clicked in the units of the current axes. The return value button is 1, 2, or 3 for the left, middle, or right button. If a key is pressed the ASCII value is returned in button.

  Implementation Note: `ginput` is intenteded for 2-D plots. For 3-D plots see the currentpoint property of the current axes which can be transformed with knowledge of the current `view` into data units.

  See also: gtext, waitforbuttonpress.

Function File: waitforbuttonpress ()
Function File: b = waitforbuttonpress ()

  Wait for mouse click or key press over the current figure window.

  The return value of b is 0 if a mouse button was pressed or 1 if a key was pressed.

  See also: waitfor, ginput, kbhit.

Function File: gtext (s)
Function File: gtext ({s1, s2, …})
Function File: gtext ({s1; s2; …})
Function File: gtext (…, prop, val, …)
Function File: h = gtext (…)

  Place text on the current figure using the mouse.

  The text is defined by the string s. If s is a cell string organized as a row vector then each string of the cell array is written to a separate line. If s is organized as a column vector then one string element of the cell array is placed for every mouse click.

  Optional property/value pairs are passed directly to the underlying text objects.

  The optional return value h is a graphics handle to the created text object(s).

  See also: ginput, text.

Function File: hui = uimenu (property, value, …)
Function File: hui = uimenu (h, property, value, …)

  Create a uimenu object and return a handle to it.

  If h is omitted then a top-level menu for the current figure is created. If h is given then a submenu relative to h is created.

  uimenu objects have the following specific properties:

  `"accelerator"`

    A string containing the key combination together with CTRL to execute this menu entry (e.g., `"x"` for CTRL+x).

  `"callback"`

    Is the function called when this menu entry is executed. It can be either a function string (e.g., `"myfun"`), a function handle (e.g., @myfun) or a cell array containing the function handle and arguments for the callback function (e.g., {@myfun, arg1, arg2}).

  `"checked"`

    Can be set `"on"` or `"off"`. Sets a mark at this menu entry.

  `"enable"`

    Can be set `"on"` or `"off"`. If disabled the menu entry cannot be selected and it is grayed out.

  `"foregroundcolor"`

    A color value setting the text color for this menu entry.

  `"label"`

    A string containing the label for this menu entry. A `"&"`-symbol can be used to mark the `"accelerator"` character (e.g., `"E&xit"`)

  `"position"`

    An scalar value containing the relative menu position. The entry with the lowest value is at the first position starting from left or top.

  `"separator"`

    Can be set `"on"` or `"off"`. If enabled it draws a separator line above the current position. It is ignored for top level entries.

  Examples:

      f = uimenu ("label", "&File", "accelerator", "f");
      e = uimenu ("label", "&Edit", "accelerator", "e");
      uimenu (f, "label", "Close", "accelerator", "q", ...
                 "callback", "close (gcf)");
      uimenu (e, "label", "Toggle &Grid", "accelerator", "g", ...
                 "callback", "grid (gca)");

  See also: figure.

Next: Test Plotting Functions, Previous: Printing and Saving Plots, Up: High-Level Plotting [Contents][Index]