Reputation: 21
I have a raster dataset that I created from iwd. I have plotted a filledContour plot but I want to reverse the x- and y-axis so that the numbers are decreasing, eliminate the white space and vertically exaggerate the y-axis. Setting the xlim and ylim as you would in ggplot or plot has not worked.
If there is no way to reverse the x- and y-axis of a raster dataset, how do I maintain the resolution of my s4 class dataset after converting to s3? For example, if I use filled.contour
instead of filledContour
.
Here is my code and plot, which is pretty basic because what I have tried has not produced any results:
idw.out <- gstat::idw(Z ~ 1, core2, grd, idp = 1.5)
r <- raster(idw.out[1])
r.contour <- filledContour(r)
r.contour
An example of the scale that I am looking for is below:
Cheers
Upvotes: 1
Views: 400
Reputation: 21
I resolved my problem with the code listed below. Because I had S4 class data, I had to manually set the axis extent to coincide with the xlim and ylim. This step is not required for 'filled.contour' plots, but is for 'filledContour' plots.
idw.out <- gstat::idw(Z ~ 1, core2, grd, idp = 1.5)
r=raster(idw.out[1], layer = 1, values=TRUE)
b = c(0,5,10,15,20,30,40,50)
col = rev(bpy.colors(length(b)-1))
r.contour = filledContour(r, zlim=c(0,50), xlim=c(9,-4), ylim=c(5.3,0),
asp = NA, xaxs = "i", yaxs = "i", las = 1,
col=col, levels=b,
xlab="grain-size (phi)", ylab="core depth (m)", main="Core 2")
Upvotes: 1