1
因此,我正在为一些数据创建热图,并且让它显示按星期几和小时汇总的车辆数量。但是,当我制作地图时,传说似乎不起作用,因此,瓷砖不会达到“最深的红色阴影”。有谁知道发生了什么事?谢谢:为什么我的ggplot geom_tile传说比我想要的要高?
Hourplus <- c(Hour, Hour, Hour, Hour, Hour, Hour, Hour, Hour)
facetgrid <- data.frame(DayofWeek, Totals5, Totals6, Totals3, Totals4, Totals1, Totals2, Totals7, Totals8)
names(facetgrid) <- c("DayofWeek", "Marine Dr NB", "Marine Dr SB", "Carman NB", "Carman SB", "Glisan NB", "Glisan SB", "Stafford NB", "Stafford SB")
facetgrid <- melt(facetgrid)
facetgrid$DayofWeek <- factor(facetgrid$DayofWeek, levels=c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
facetgrid
levels(facetgrid$DayofWeek) <- c("M","Tu","W","Th","F","Sa","Su")
gg <- ggplot(facetgrid, aes(x=Hourplus, y=DayofWeek, fill=value)) + geom_tile(color="white", size=0.1) + facet_wrap(~variable, ncol = 2, scales='free')
gg <- gg + coord_equal()
gg <- gg + labs(x=NULL, y=NULL, title ="May 2017: Volume of Vehicles Greater than 20ft in Length")
gg <- gg + theme_tufte()
gg <- gg + theme(plot.title=element_text(hjust=0.5))
gg <- gg + theme(axis.ticks=element_blank())
gg <- gg + theme(axis.text=element_text(size=7))
gg <- gg + theme(legend.title=element_text(size=8))
gg <- gg + theme(legend.text=element_text(size=6))
gg <- gg + scale_fill_gradient(low = "white",high = "red", name="Volume")
gg <- gg + scale_x_continuous(breaks=seq(0,24,4), limits=c(0,25))
ggsave("8stationsvol.png", height =8, width = 12)
这是地图是什么样子,现在(没有砖是最黑暗的红色)
我可以建议从oldish红色/白色调色板切换到'viridis'吗? https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html从白色背景上的'low ='white''似乎并不是一个好主意。 – PoGibas
感谢您的建议,但我的雇主希望它是这样的。我现在真的只是想解决这个问题 –