Paul Paul - 22 days ago 4x
R Question

Converting a matrix into a gray scale image in R

I have the following vector:


And would like to reshape it into a matrix of the form 33 X 28. Then convert the matrix into a gray scale pixel like image.

In MATLAB, I know there exists imagesc and imshow to convert the matrix into an image. Is there something similar in R ?

Also, can the mean and maximum be adjusted like in MATLAB for the gray scale intensity?


You are looking for ?heatmap:



You can adjust the min/max color via the col argument. Look at ?image, ?heat.colors and friends.