我正在努力讓 geom_hex 填充某個變數。我的目標是讓 geom_hex 填充變數 xRV,較低的值為紅色,較高的值為藍色,但就目前情況而言,我得到的只是灰色的六邊形。
這是 df:
IVB <- c(10, 15, 20, 17, 17.5, 20, 17, 16.5, 21.3, 12.5, 10.9)
RelZ <- c(66, 75, 70, 67, 68.3, 67.6, 70.3, 72, 65.3, 55.6, 71)
xRV <- c(-.01, .13, -.15, .5, -.03, -.06, .07, .1, -.02, .05, .01)
miheat <- data.frame(IVB, RelZ, xRV)
這是我一直在運行但沒有作業的代碼:
library(ggplot2)
library(hexbin)
ggplot(miheat, aes(x = RelZ, y = IVB)) geom_hex(aes(fill = xRV)) scale_fill_gradient2(low = "red" , mid = "white" , high = "blue", space = "Lab")

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/364229.html
上一篇:ggplot:定義點重疊的顏色
下一篇:分組資料上的ggplot方面
