I want to plot some sf data, similar to this example:

library (sf)

fishnet <- st_make_grid ()
n <- length (fishnet)
vals <- rlnorm (n)
fishnet <- st_sf (fishnet)
fishnet <- cbind (fishnet, vals)

c_ramp <- colorRampPalette (c ("azure", "yellow", "red"))
plot (fishnet, pal  = c_ramp)

I want to use a log scale for the legend and color scheme, but the plot function doesn't seem to support log scale out of the box. Is there any painless way around that?


In looking at the code underlying the plot_sf function, it seems like the path of least resistance is to just create a new column with the log transformed values. If one could call y separately you could transform the values on the fly but, currently the plot generic is not written in that way.

fishnet$log.vals <- log(fishnet$vals)
plot(fishnet[,"log.vals"], pal  = c_ramp)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.