【问题标题】:Example of ggplot2 stat_summary_hex using alpha aesthetic mapping?使用 alpha 美学映射的 ggplot2 stat_summary_hex 示例?
【发布时间】:2013-08-26 20:25:49
【问题描述】:

我正在使用 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 的汇总值的alpha 为0。但是,它看起来像stat_summary_hex不承认alpha 审美。

有人有stat_summary_hexalpha 映射的示例吗?

【问题讨论】:

  • 感谢@Henrik 的格式化建议

标签: r ggplot2 alpha


【解决方案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})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-15
    • 2019-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多