Bug 14833 - Using 'axis' overshoots lower plotting region limit for logged plots
Using 'axis' overshoots lower plotting region limit for logged plots
Status: RESOLVED FIXED
Product: R
Classification: Unclassified
Component: Graphics
R 2.12.1
x86_64/x64/amd64 (64-bit) Linux-Ubuntu
: P5 trivial
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-04 16:39 UTC by Lee Kelvin
Modified: 2012-03-18 11:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lee Kelvin 2012-03-04 16:39:48 UTC
Hello, 

When plotting a logged axis plot and using 'axis' to add an additional axis with manual tick mark locations, the lower boundary overshoots the plotting region. 

Example:
> plot(tan, xlim=c(1e5, 1e12), log="x")
> axis(side=3, at=c(1e4, 1e100))

As you can see when plotting the above example, the lower axis overshoots the plotting area whilst the upper limit, despite a very large 'at' value, is automatically clipped at the upper limit of the plotting region. 

I would naively expect the lower axis to be clipped at the lower limit of the plotting region in a similar manner to the upper limit. The fact that it does not is somewhat inconsistent in how axis handles the lower and upper limits. 

This bug does not appear if the relative range of xlim is smaller. 

I have the need to specify 'axis' ranges outside the plotting region as it allows me to trivially have minor tick marks trailing all the way to the edge of the plot. These minor axes then replace the need for the use of 'box' to create an enclosed plotting region. If left unfixed, this bug would limit my options in this regard to either an overshot axis, or a plotting region with a gap in its bounding box. 

I have tested this on a Mac OSX system, only to find the same issue reappearing. 

I hope I have provided enough explanation both of the bug and my need for specifying unusually large axis limits outside of the range of the plotting region. Even if not, there is currently an inconsistency here within R regards the handling of the lower and upper limits. 

Thank you in advance, 

Regards
Comment 1 Duncan Murdoch 2012-03-14 18:06:36 UTC
The problem was that the axes were calculated to be a fraction epsilon outside the range of the user coordinates, where epsilon is about 2 e-16.  But when your axis range is about 1e12, that's a sizeable number, and it ended up with the lower limit around -50000 in your example.

I'll fix it and commit shortly.
Comment 2 Duncan Murdoch 2012-03-14 18:17:18 UTC
Sorry, wrong epsilon -- the one used here is the single precision one.
Comment 3 Lee Kelvin 2012-03-18 11:14:53 UTC
Thank you very much for fixing this!  

It has frustrated me for some time, much appreciated.

Regards,

(In reply to comment #2)
> Sorry, wrong epsilon -- the one used here is the single precision one.