Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalents of matlab's pcolor in R?

I have a 16x16 matrix of grayscale values representing handwriting digits. Is there a plot in R that I can use to visualize it?

Matlab has pcolor, I am looking for something along those lines. pcolor

like image 957
signalseeker Avatar asked Jan 20 '10 16:01

signalseeker


2 Answers

No need to go to extra packages. Base R already has this, see

  • help(image)

  • help(heatmap)

and Romain's excellent R Graph Gallery which has a searchable index.

like image 94
Dirk Eddelbuettel Avatar answered Sep 19 '22 07:09

Dirk Eddelbuettel


There are many options for something like this. One option is to use the geom_tile in ggplot2:

library(ggplot2)
ggplot(melt(volcano), aes(x=X1, y=X2, fill=value)) + geom_tile()

Ends up looking like this: alt text
(source: had.co.nz)

Some other options include: levelplot (in lattice) or color2D.matplot (in plotrix).

like image 39
Shane Avatar answered Sep 21 '22 07:09

Shane