简体   繁体   English

ggplot2错误:创建渐变贴图时将离散值提供给连续刻度

[英]ggplot2 Error: Discrete value supplied to continuous scale when creating gradient map

This has been asked before but I can't get any previous solutions to work.之前已经有人问过这个问题,但我无法获得以前的任何解决方案。

I am trying to create a map (works) which colours on a gradient according to the data set I'm feeding into it (doesn't work).我正在尝试创建一个地图(有效),该地图根据我要输入的数据集在渐变上进行着色(不起作用)。

Currently I have the following目前我有以下

plot1 <- ggplot(map, aes(x=long, y = lat, group = group, fill = map$`data`)) + geom_polygon(colour="white") + coord_map("polyconic") 

plot1 <- plot1 + ggtitle("Data")
plot1 <- plot1 + scale_fill_gradient2(low = "#559999", mid = "grey", high = "#BB650B")

My data set is currently set up as the following我的数据集当前设置如下

map region: chr, long: num, lat: num, group: num, order: int, data: num地图区域:hr,long:num,lat:num,group:num,order:int,data:num

Any ideas?有任何想法吗?

This has been asked before but I can't get any previous solutions to work.之前已经有人问过这个问题,但我无法获得以前的任何解决方案。

I am trying to create a map (works) which colours on a gradient according to the data set I'm feeding into it (doesn't work).我正在尝试创建一个地图(有效),该地图根据我要输入的数据集在渐变上进行着色(不起作用)。

Currently I have the following目前我有以下

plot1 <- ggplot(map, aes(x=long, y = lat, group = group, fill = map$`data`)) + geom_polygon(colour="white") + coord_map("polyconic") 

plot1 <- plot1 + ggtitle("Data")
plot1 <- plot1 + scale_fill_gradient2(low = "#559999", mid = "grey", high = "#BB650B")

My data set is currently set up as the following我的数据集当前设置如下

map region: chr, long: num, lat: num, group: num, order: int, data: num地图区域:hr,long:num,lat:num,group:num,order:int,data:num

Any ideas?有任何想法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM