octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #52185] Make it possible to position annotatio


From: Pantxo Diribarne
Subject: [Octave-bug-tracker] [bug #52185] Make it possible to position annotations relative to axes or data
Date: Mon, 9 Oct 2017 07:24:53 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #2, bug #52185 (project octave):

Hi,

The simplest solution I can think of is to add listeners to the axes
properties:


function [retval] = update_annot_pos (hax, ev, han, coord)
  if (! ishandle (han))
    return
  endif
  ## Convert axes coordinates into normalized coordinates
  xl = xlim (hax);
  yl = ylim (hax);
  x0 = (coord(1) - xl(1)) / diff(xl);
  y0 = (coord(2) - yl(1)) / diff(yl);

  ## Assume axes units is normalized
  
  pos = get (hax, "position");
  x0 = x0*pos(3) + pos(1);
  y0 = y0*pos(4) + pos(2);
  
  pos = get (han, "position");
  pos(3) = x0-pos(1);
  pos(4) = y0-pos(2);
  set (han, "position", pos);
  drawnow ();
endfunction

plot (1:10, "-o")
h = annotation ("textarrow", [.2 .4], [.6 .6], "string", "toto"); 
addlistener (gca, "xlim", address@hidden, h, [5 5]})
addlistener (gca, "ylim", address@hidden, h, [5 5]})
addlistener (gca, "position", address@hidden, h, [5 5]})



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?52185>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]