I'm working with the following code:
library('colorspace')
blups <- brewer.pal(9, 'BuPu')
geom_tile(aes(lon, lat, fill = predicted_price), alpha = 0.8) + scale_fill_gradientn(colors = blups)
The error msg is:
Check your call of scale_fill_gradientn(). Did you correctly specify the argument colors?
I've tried various combinations of code, and the error msg is always the same.
What's going on?
Try this: You need library(RColorBrewer)
library(RColorBrewer)
blups <- brewer.pal(9, 'BuPu')
# Example data:
library(reshape)
# Data
set.seed(8)
m <- matrix(round(rnorm(200), 2), 10, 10)
colnames(m) <- paste("Col", 1:10)
rownames(m) <- paste("Row", 1:10)
# Transform the matrix in long format
df <- melt(m)
colnames(df) <- c("x", "y", "value")
library(ggplot2)
ggplot(df, aes(x = x, y = y, fill = value)) +
geom_tile()+
scale_fill_gradientn(colors = blups)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.