comparison scripts/plot/draw/polar.m @ 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 42b7d7758c4a
children 421e3ebfca8d
comparison
equal deleted inserted replaced
20410:31f89b12aaf7 20411:e2feb806332a
154 154
155 endfunction 155 endfunction
156 156
157 function rtick = __calc_rtick__ (hax, maxr) 157 function rtick = __calc_rtick__ (hax, maxr)
158 ## FIXME: workaround: calculate r(ho)tick from xtick 158 ## FIXME: workaround: calculate r(ho)tick from xtick
159 ## It would be better to just calculate the values,
160 ## but that code is deep in the C++ for the plot engines.
159 savexlim = get (hax, "xlim"); 161 savexlim = get (hax, "xlim");
160 saveylim = get (hax, "ylim"); 162 saveylim = get (hax, "ylim");
161 set (hax, "xlim", [-maxr maxr], "ylim", [-maxr maxr]); 163 set (hax, "xlim", [-maxr maxr], "ylim", [-maxr maxr]);
162 xtick = get (hax, "xtick"); 164 xtick = get (hax, "xtick");
163 rtick = xtick(find (xtick > 0, 1):find (xtick >= maxr, 1)); 165 minidx = find (xtick > 0, 1);
164 if (isempty (rtick)) 166 maxidx = find (xtick >= maxr, 1);
165 rtick = [0.5 1]; 167 if (! isempty (maxidx))
168 rtick = xtick(minidx:maxidx);
169 else
170 ## Add one more tick through linear interpolation
171 rtick = xtick(minidx:end);
172 rtick(end+1) = xtick(end) + diff (xtick(end-1:end));
166 endif 173 endif
167 set (hax, "xlim", savexlim, "ylim", saveylim); 174 set (hax, "xlim", savexlim, "ylim", saveylim);
168 endfunction 175 endfunction
169 176
170 function retval = __plr1__ (h, theta, fmt) 177 function retval = __plr1__ (h, theta, fmt)