Bug 14632 - misalignment of output from hist()/rect() in windows() device in R-2.13.1
misalignment of output from hist()/rect() in windows() device in R-2.13.1
Status: RESOLVED DUPLICATE of bug 14628
Product: R
Classification: Unclassified
Component: Windows GUI / Window specific
R 2.13.1 patched
Other Windows 64-bit
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-16 16:22 UTC by Tony Plate
Modified: 2011-07-18 12:26 UTC (History)
1 user (show)

See Also:


Attachments
Output showing 4 plots with misaligned rect() output (6.57 KB, image/png)
2011-07-16 16:22 UTC, Tony Plate
Details
Output of hist() showing misaligned bottoms of bars. (5.07 KB, image/png)
2011-07-17 04:52 UTC, Tony Plate
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Plate 2011-07-16 16:22:57 UTC
Created attachment 1210 [details]
Output showing 4 plots with misaligned rect() output

In the windows() device() in R-2.13.1, the plots produced by a call like hist(rnorm(500)) have uneven bottoms on the rectangles.
This is running under Windows XP 64 bit.  Both the 32 and 64 bit versions of R show the same behavior.

The problem appears to be restricted to the windows() device in R-2.13.1 and later.
  * The problem does not appear with R-2.13.0.
  * The problem does not appear under R-2.13.1 with the X11() running under Ubuntu.
  * The problem is present in R-2.13.1 patched and R-devel build r56380 (doing to par(ylbias=0.1) in R-devel doesn't make any difference)
  * The problem does not appear under Windows when using a cairo device (Cairo() from package cairoDevice), or when using the pdf() device.
  * The problem appears when drawing rectangles directly with rect() (some sides that should be aligned are not, see below).
  * The problem does not seem to appear when drawing line segments with segments()

Minimal self contained example:
> set.seed(0)
> hist(rnorm(500))

Output is can be seen at: https://docs.google.com/leaf?id=0B58TiYOG3IpvNmExM2ZkMjEtMjRmZS00OTE0LTgxODAtYzk0NGIxMTMwMDU4&hl=en_US

More clues:

> windows(height=7, width=7)
> par(oma=c(0,0,2,0))
> par(mfrow=c(2,2))
> par(mar=c(2,2,2,1))
> par(mgp=c(1.5,0.7,0))
> n <- 20
> n1 <- n - 1
>
> plot(0:n, 0:n, type='n', main='misaligned bottoms', xlab="", ylab="")
> rect(0:n1,0,1:n,1:n)
> plot(0:n, 0:n, type='n', main='ok', xlab="", ylab="")
> rect(yb=0:n1,xl=0,yt=1:n,xr=1:n)
> plot(0:n, 0:n, type='n', main='ok', xlab="", ylab="")
> rect(0:n1,yt=n,1:n,yb=1:n)
> plot(0:n, 0:n, type='n', main='misaligned right', xlab="", ylab="")
> rect(yb=0:n1,xr=n,yt=1:n,xl=1:n)
> mtext(outer=T, side=3, version$version)
> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252  
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                         
[5] LC_TIME=English_United States.1252   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    
>

Output of the above can be seen at: https://docs.google.com/leaf?id=0B58TiYOG3IpvMThiNGU1ZWQtYzUzMy00YjM4LWFjMmMtNmIwOGZmZWE1ZGJl&hl=en_US

Additionally, lines from segments() don't seem to have problems lining up:
> plot(0:n, 0:n, type='n', main='ok', xlab="", ylab="")
> segments(0:n1,n/2,1:n,n/2)
> segments(y0=0:n1,x0=n/2,y1=1:n,x1=n/2)
>
Comment 1 Tony Plate 2011-07-17 04:52:54 UTC
Created attachment 1211 [details]
Output of hist() showing misaligned bottoms of bars.
Comment 2 Duncan Murdoch 2011-07-18 12:26:17 UTC
The fix for 14583 led to both of these reports.

*** This bug has been marked as a duplicate of bug 14628 ***