2013-08-26 68 views
2

我正在使用ggplot2stat_summary_hex函數繪製客戶流失。使用阿爾法美學映射的ggplot2 stat_summary_hex示例?

stat_summary_hex(aes(x = Lon, y = Lat, z = Churn), 
    bins=100, colour = NA, geom = "hex", fun = function(x) sum(x)) 

ScaleFill <- scale_fill_gradient2(low = "blue", high = "orange", na.value = NA) 

的stat_summary_hex繪製了從get_map底圖,所以我想設置alpha規模,使得接近於0的彙總值將有0的alpha但是,它看起來像stat_summary_hex不承認的alpha美感。

有人有stat_summary_hexalpha映射的例子嗎?

+0

感謝格式化建議@Henrik – jclouse

回答

1

我發現周圍的工作通過設置drop = TRUE,然後改變stat_summary_hex函數返回NA當結果小於閾值的我:

stat_summary_hex(aes(x = Lon, y = Lat, z = Churn), 
    bins=100, colour = NA, geom = "hex", drop = TRUE, 
    fun = function(x) if(abs(sum(x)) > 5) {sum(x)} else {NA})