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

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

[Octave-bug-tracker] [bug #39552] quiver/quiver3 ignores scale with only


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #39552] quiver/quiver3 ignores scale with only one point to plot
Date: Thu, 20 Apr 2023 11:41:26 -0400 (EDT)

Follow-up Comment #25, bug #39552 (project octave):

i saw the same, but this seems to work:


%!test <*39552> # Check arrow length and scale factor adjustment.
%! hf = figure ("visible", "off");
%! hax = gca ();
%! unwind_protect
%!   [x,y] = meshgrid (1:2);
%!   u = [0 1; 2 3];
%!   v = [1 2; 3 4];
%!   numpts = numel (x);
%!   sf = 0.5;
%!
%!   ## Check single arrow.
%!   h = quiver (hax, x(4), y(4), u(4), v(4), 1);
%!   child = find (cellfun ( ...
%!                  @numel, {get(get (h, "children")).xdata}) == 3);
%!   xendpoint = get (get (h, "children")(child), "xdata")(2);
%!   assert (xendpoint, x(4) + u(4), eps);
%!   h = quiver (hax, x(4), y(4), u(4), v(4), sf);
%!   child = find (cellfun( ...
%!                  @numel, {get(get (h, "children")).xdata}) == 3);
%!   xendpoint = get (get (h, "children")(child), "xdata")(2);
%!   assert (xendpoint, x(4) + sf*u(4), eps);
%!
%!   ## Check multiple arrows.
%!   numpts = 4;
%!   h = quiver (hax, x, y, u, v, 1);
%!   child = find (cellfun ( ...
%!                  @numel, {get(get (h, "children")).xdata}) == 3*numpts);
%!   xendpoint1 = get (get (h, "children")(child), "xdata")(5);
%!   assert (xendpoint1, x(2) + (sqrt(2)/10)*u(2), eps);
%!   xendpoint2 = get (get (h, "children")(child), "xdata")(11);
%!   assert (xendpoint2, x(4) + (sqrt(2)/10)*u(4), eps);
%!   h = quiver (hax, x, y, u, v, sf);
%!   child = find (cellfun ( ...
%!                  @numel, {get(get (h, "children")).xdata}) == 3*numpts);
%!   xendpoint1 = get (get (h, "children")(child), "xdata")(5);
%!   assert (xendpoint1, x(2) + sf*(sqrt(2)/10)*u(2), eps);
%!   xendpoint2 = get (get (h, "children")(child), "xdata")(11);
%!   assert (xendpoint2, x(4) + sf*(sqrt(2)/10)*u(4), eps);
%!
%! unwind_protect_cleanup
%!   close (hf);
%! end_unwind_protect


If you think that's too needlessly complicated, I could push the comment #14
version, along with a comment in `__quiver__` that changing the ordering will
break BISTS in quiver.m and would need to be updated.  But since the test
above works, and shouldn't be fragile to other changes, I think it should be
okay to use.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?39552>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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