No gradient of color with geom_raster

ggplot2, r

Solution

EDITED to emphasize the key answer

The code in the question with the provided dataset achieves the desired result:

After discussion in the comments, the key lesson turns out to be a suggestion that when the system behaves strangely, it may be wise to `update.packages()` as part of troubleshooting.

Problem

I'm trying to plot a raster image (ocean bathymetry) with geom_raster but I'm having a hard time to crack down the code. I would appreciate any help. I've downloaded the following xyz file (Dropbox link). ``` SF.bath <- read.table("SF_bath.txt", header=F,col.names=c("lon","lat","z")) > head(SF.bath) lon lat z 1 -67.9917 50.9968 757 2 -67.9750 50.9968 693 3 -67.9583 50.9968 673 4 -67.9417 50.9968 769 5 -67.9250 50.9968 761 6 -67.9084 50.9968 733 ``` When I try the following code, the colours do not show on my map? ``` v <- ggplot(SF.bath, aes(lon, lat,z=z)) print(v + geom_raster(aes(fill=z)) + stat_contour(size=0.2) + scale_fill_gradient("z")) ``` I get the following message: `Using alpha as value column: use value_var to override.` Any ideas of what might be the problem?

Original source