Here is an alternative way to solve the problem. Included in the example are ways to add margins with axes information, how to normalize and floor the data to be plotted + use a colour (blue) for a specific level (zero). Substitute and with the specific data you want to use and change {lm, bm, tm, rm} to different values to resize the four margins (all measures in pixels):
maxv <- 500
v <- t(<matrix>)
d <- <vector>
di <- <vector>
dm <- <vector>
nr <- nrow(v)
nc <- ncol(v)
library(grid)
vnorm <- v
for (r in 1:nr) {
for (c in 1:nc) {
vnorm[r,c] <- min(1, v[r, nc-c+1]/500)
if (vnorm[r,c] == 0) {vnorm[r,c] <- "blue"}
else {vnorm[r,c] <- grey(vnorm[r,c])}
}
}
vnorm <- t(vnorm)
x <- seq(1, nr)
y <- rep(1, nr)
xrange <- range(d)
yrange <- c(0, 24)
bm <- 90
lm <- 40
tm <- 12
rm <- 12
png(file="graph.png", width=nr+lm+rm, height=nc+tm+bm)
par(mai=c(bm/72, lm/72, tm/72, rm/72))
plot(d, y, ann=FALSE, xlim=xrange, ylim=yrange, axes=FALSE, xaxs="i", yaxs="i")
axis(1, at=dm,labels=dm, col.axis="black", las=2)
axis(2, at=seq(0,24),labels=seq(0,24), col.axis="black", las=2)
rasterImage(vnorm, xrange[1], yrange[1], xrange[2], yrange[2], interpolate=FALSE)
dev.off()