Problem
As I experiment with heatmaps, here's a circular question, with a likely disgustingly obvious answer ...
I answered the question about building a heat map with heterogeneous data using the fields
and ggplot2
. It basically allows you to interpolate differently scaled x and y axes with the akima
package, ready for construction.
Unfortunately, I cannot find a way to move the axes so that they return to their original values. I know that this will be due to the use of the breaks
and labels
parameters in ggplot2
, but I could not do anything but errors. Solutions for both build packages would be much appreciated ...
Updated with solution
For convenience, here is my code using ggplot2
:
library("akima") library("ggplot2") x.orig <- rnorm(20, 4, 3) y.orig <- rnorm(20, 5e-5, 1e-5) x <- scale(x.orig) y <- scale(y.orig) z <- rnorm(20) t. <- interp(x,y,z) t.df <- data.frame(t.) gt <- data.frame( expand.grid(x=t.$x, y=t.$y), z=c(t.$z), value=cut(c(t.$z), breaks=seq(min(z),max(z),0.25))) p <- ggplot(gt) + geom_tile(aes(x,y,fill=value)) + geom_contour(aes(x=x,y=y,z=z), colour="black")
Result
It remains to be decided
One problem remains: the first time you run the code, it generates labels in the reverse order; in the second and subsequent runs, the labels are correctly marked. Maybe another question? ...