I am wondering about the possibility to smooth the plot or make it somehow better, since now the pixels are too big.
library(ggplot2)
library(reshape2)
# plot2d = melt(c)
plot2d = melt(matrix(rnorm(20), 5)) # fake data
names(plot2d) <- c("x", "y", "z")
v <- ggplot(plot2d, aes(x, y, z = z))
v + geom_tile(aes(fill = z)) +
scale_alpha_continuous(limits=c(start.point, end.point)) +
scale_fill_gradient2('TYYYT',low="green", mid = "white", high="red")
The easiest way to smooth this plot is to use
geom_raster()
withinterpolate=TRUE
(see?geom_tile
for other advantages).You can also do (bilinear) interpolation by hand, using the
fields
package (there are lots of options: e.g.library(sos); findFn("{bilinear interpolation}")
.Now melt it and replot:
Hmm, the interpolation seems to have changed the z-scale - you should be careful with that ...