changeset 20411:e2feb806332a

polar.m: Calculate 'rtick' property more accurately (bug #45513). * polar.m (__calc_rtick__): if maximum rho value is above last rtick, then extend rtick value through linear interpolation.
author Rik <rik@octave.org>
date Thu, 23 Jul 2015 08:45:45 -0700
parents 31f89b12aaf7
children f248847b5071
files scripts/plot/draw/polar.m
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/polar.m	Wed Jul 22 20:27:11 2015 -0400
+++ b/scripts/plot/draw/polar.m	Thu Jul 23 08:45:45 2015 -0700
@@ -156,13 +156,20 @@
 
 function rtick = __calc_rtick__ (hax, maxr)
   ## FIXME: workaround: calculate r(ho)tick from xtick
+  ##        It would be better to just calculate the values,
+  ##        but that code is deep in the C++ for the plot engines.
   savexlim = get (hax, "xlim");
   saveylim = get (hax, "ylim");
   set (hax, "xlim", [-maxr maxr], "ylim", [-maxr maxr]);
   xtick = get (hax, "xtick");
-  rtick = xtick(find (xtick > 0, 1):find (xtick >= maxr, 1));
-  if (isempty (rtick))
-    rtick = [0.5 1];
+  minidx = find (xtick > 0, 1);
+  maxidx = find (xtick >= maxr, 1);
+  if (! isempty (maxidx))
+    rtick = xtick(minidx:maxidx);
+  else
+    ## Add one more tick through linear interpolation
+    rtick = xtick(minidx:end);
+    rtick(end+1) = xtick(end) + diff (xtick(end-1:end));
   endif
   set (hax, "xlim", savexlim, "ylim", saveylim);
 endfunction