Bug 14774 - image() rotates one-column 'z' with 'useRaster=TRUE'
image() rotates one-column 'z' with 'useRaster=TRUE'
Status: RESOLVED FIXED
Product: R
Classification: Unclassified
Component: Graphics
R 2.14.1 patched
x86_64/x64/amd64 (64-bit) Linux
: P5 minor
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-05 14:21 UTC by Mikko Korpela
Modified: 2012-01-05 15:31 UTC (History)
1 user (show)

See Also:


Attachments
The bug visualized (8.13 KB, application/force-download)
2012-01-05 14:21 UTC, Mikko Korpela
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikko Korpela 2012-01-05 14:21:32 UTC
Created attachment 1257 [details]
The bug visualized

Overview:
When the image() function is given a one-column matrix 'z', 'useRaster=TRUE' causes the output to show one column of pixels instead of one row, where the latter is the documented behaviour. The bug can be circumvented by using two identical columns in 'z' (rows in the output). Confirmed on x11() and pdf() devices.

Steps to Reproduce (outputs a PDF file, also attached):

library(graphics)
library(grDevices)
n.colors <- 128
h.gradient <- matrix(1 : n.colors, n.colors, 1)
black.to.white <- colorRampPalette(c("black", "white"))(n.colors)
pdf(file = "image_bug.pdf")
image(z = h.gradient, col = black.to.white, useRaster = FALSE)
title("useRaster = FALSE, one row (fine)")
image(z = h.gradient, col = black.to.white, useRaster = TRUE)
title("useRaster = TRUE, one row (wrong orientation)")
image(z = cbind(h.gradient, h.gradient), col = black.to.white, useRaster = TRUE)
title("useRaster = TRUE, two rows (fine again)")
dev.off()

Actual Results:
The second page of the PDF is a vertical gradient.

Expected Results:
A horizontal gradient, such as on pages 1 and 3.

> sessionInfo()
R version 2.14.1 Patched (2012-01-02 r58038)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
 [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8   
 [7] LC_PAPER=C                LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
Comment 1 Peter Dalgaard 2012-01-05 15:31:39 UTC
Missing drop=FALSE inside image.default

BTW: Easier reproduction instructions:

x <- cbind(1:10)
image(x)
image(x, useRaster=TRUE)
Comment 2 Peter Dalgaard 2012-01-05 19:41:23 UTC
Missing drop=FALSE in image.default, will fix.

-pd


On Jan 5, 2012, at 14:21 , <r-bugs@r-project.org> <r-bugs@r-project.org> wrote:

> https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14774
> 
>           Summary: image() rotates one-column 'z' with 'useRaster=TRUE'
>           Product: R
>           Version: R 2.14.1 patched
>          Platform: x86_64/x64/amd64 (64-bit)
>        OS/Version: Linux
>            Status: NEW
>          Severity: minor
>          Priority: P5
>         Component: Graphics
>        AssignedTo: R-core@R-project.org
>        ReportedBy: mvkorpel@iki.fi
>   Estimated Hours: 0.0
> 
> 
> Created an attachment (id=1257)
> --> (https://bugs.r-project.org/bugzilla3/attachment.cgi?id=1257)
> The bug visualized
> 
> Overview:
> When the image() function is given a one-column matrix 'z', 'useRaster=TRUE'
> causes the output to show one column of pixels instead of one row, where the
> latter is the documented behaviour. The bug can be circumvented by using two
> identical columns in 'z' (rows in the output). Confirmed on x11() and pdf()
> devices.
> 
> Steps to Reproduce (outputs a PDF file, also attached):
> 
> library(graphics)
> library(grDevices)
> n.colors <- 128
> h.gradient <- matrix(1 : n.colors, n.colors, 1)
> black.to.white <- colorRampPalette(c("black", "white"))(n.colors)
> pdf(file = "image_bug.pdf")
> image(z = h.gradient, col = black.to.white, useRaster = FALSE)
> title("useRaster = FALSE, one row (fine)")
> image(z = h.gradient, col = black.to.white, useRaster = TRUE)
> title("useRaster = TRUE, one row (wrong orientation)")
> image(z = cbind(h.gradient, h.gradient), col = black.to.white, useRaster =
> TRUE)
> title("useRaster = TRUE, two rows (fine again)")
> dev.off()
> 
> Actual Results:
> The second page of the PDF is a vertical gradient.
> 
> Expected Results:
> A horizontal gradient, such as on pages 1 and 3.
> 
>> sessionInfo()
> R version 2.14.1 Patched (2012-01-02 r58038)
> Platform: x86_64-unknown-linux-gnu (64-bit)
> 
> locale:
> [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             
> [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
> [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8   
> [7] LC_PAPER=C                LC_NAME=C                
> [9] LC_ADDRESS=C              LC_TELEPHONE=C           
> [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> -- 
> Configure bugmail: https://bugs.r-project.org/bugzilla3/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
> 
> _______________________________________________
> R-core list: https://stat.ethz.ch/mailman/listinfo/r-core
> 

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes@cbs.dk  Priv: PDalgd@gmail.com