r - How to output geom_raster() to a raster image? -
I am doing quantitative image analysis, and looking at results ggplot2. In the original image there is a datapoint in output for each pixel.
Is there an easy way to output pixels, and only pixels in an image file? No legend, no ax, nothing but pixels let me have columns for Here's a way: < / P> geom_raster () Imagines my data in R well. But it would be good for a raster image , in this way, I flipped through several derived images using a light image viewer (e.g.,
feh ) I can, and pixels will have to be raised altogether.
data.frame in the
line and
call And the desired output resolution is also known.
Library (ggplot2) library ( Reshape2) # to melt (...) n & lt; - 100 sets.seed (1) #productive example img & lt; - Matrix (rnorm (n ^ 2,30,3), nc = n) gg & lt; - Melt (data. Frames (x = 1: n, img), id = "x") ggplot (gg) + geom_raster (aes (x = x, y = variable, fill = value)) + scale_x_continuous (extension = c (0,0)) + # Extra space (fill = FALSE) + # on the x-axis guides to get rid off the legend theme (axis text = element_blank), close axis = axis = axis = Element_blank (), axis.title = element_blank ())
Comments
Post a Comment