From: Hans-Bernhard B. <br...@ph...> - 2004-08-08 16:08:12
|
On Thu, 5 Aug 2004, Daniel J Sebald wrote: > set xrange [0:1.99805] > set grid > plot sin(x) > set xrange [0:2] > replot > set xrange [0:1.99805] > replot > > You should notice this behavior on the right border toggling back and > forth. So, yes it does seem that the border is being drawn a pixel to > the left because of the 1.99805. No. The border is drawn at exactly the same place in all cases. The bug here is that there should simply be no tick, and thus no grid line either, at x==2.0 if the range is [0:1.998]. And yes, that is a rounding problem. It's the line just above the two comments of mine you already pointed out. Citing gen_tics(), axis.c:1047: /*{{{ a few tweaks and checks */ /* watch rounding errors */ end += SIGNIF * step; /* HBB 20011002: adjusting the endpoints doesn't make sense if * some oversmart user used a ticstep (much) larger than the * yrange itself */ if (step < (fabs(lmax) + fabs(lmin))) { internal_max = lmax + step * SIGNIF; internal_min = lmin - step * SIGNIF; } else { internal_max = lmax; internal_min = lmin; } SIGNIF is 0.01, and that's the whole story. It would be tempting to just get rid of that line fiddling around with 'end', but I doubt that's a smart idea --- I'm quite sure this line was put there for a good reason. The test case is quite unrealistic, actually --- users would almost certainly never make such a choice consciously. The code may accidentally run into even narrower misses by numerical inaccuracy though (e.g. in the case at hand, 2.0 +/- 10 * DBL_EPSILON would be likely), and has to protect against those. In other words: this failure of the code to behave properly is largely caused by the requirements having changed since we added zooming by mouse. Before that, users would have known better than to select such a strange range endpoint, or they would have been using autoscaling, which would have rounded an endpoint of 1.99805 to 2.0 before it could cause any trouble. So, what I guess this means is that mouse zooms should be polished some, before being used, just like autoscaled data ranges are. > If you run gnuplot without the -nofeedback option, the feedback will > slightly readjust the x length and the rounding will behave differently. If so, that's another likely bug. -- Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |