Tôi đang cố tạo bản đồ choropleth của Hoa Kỳ có màu mặc định thay đổi từ xám sang trắng.Làm cách nào để thay đổi màu NA từ xám sang trắng trong bản đồ ggplot choropleth?
Tôi có hồ sơ cho 18 trong số 48 tiểu bang và mã hoạt động với màu theo giá trị, nhưng đối với những tiểu bang mà tôi không có hồ sơ, các trạng thái có màu xám. Tôi muốn chúng có màu trắng.
Làm cách nào để thay đổi màu?
library(maps)
library(plyr)
library(ggplot2)
records1<-read.csv('E:/My Documents/records_by_state.csv')
records<-data.frame(state=tolower(rownames(records1)), records1)
head(records)
all_states<-map_data("state")
head(all_states)
record_map<-merge(all_states, records, by.x="region", by.y="state.name")
record_map<-arrange(record_map, group, order)
head(record_map)
p<- ggplot()
p<- p + geom_polygon(data=record_map, aes(x=long, y=lat, group=group, fill=record_map$Records), colour="black"
)+ scale_fill_continuous(low="thistle2", high="darkred", guide="colorbar")
P1 <- p + theme_bw() +labs(fill= "Records by State"
, title= "By State", x="", y="")
P1 + scale_y_continuous(breaks=c()) + scale_x_continuous(breaks=c()) + theme(panel.border= element_blank())
Cảm ơn bạn - SO nhiều ---- THANK YOU – user2320821
FYI: na.value = "transparent" sẽ xóa hoàn toàn –