2

有谁知道 ggridges::geom_ridges_density_gradient 中的着色是否可以由第三个变量控制?

为了解释,如果我在林肯 NE 绘制风向的脊图(从 中的示例修改help(geom_ridges_density_gradient)),我可以根据 x(此处为风向)或 y(月)着色。例如,下面会生成一个很好的图形,显示流行度从晚秋到早春的 NW 风和其他月份的 SE 风。

ggplot(lincoln_weather, aes(x = `WindDir [Degrees]`, y = `Month`, fill = stat(x))) +
     geom_density_ridges_gradient(bandwidth=22.5) + 
     scale_fill_viridis_c(name = "Temp. [F]", option = "C") + xlim(0,360)

风向在林肯东北

最好根据每个(月乘以方向)的平均风速对其进行着色。仅仅将风速添加为填充变量并不能完成这项工作,而是返回一个灰色的单色图像。

ggplot(lincoln_weather, aes(x = `WindDir [Degrees]`, y = `Month`, fill = (`Mean Wind Speed[MPH]`))) +
 geom_density_ridges_gradient(bandwidth=22.5) + 
scale_fill_viridis_c(name = "Wind direction (°)", option = "C") + xlim(0,360)

我找不到色阶由除fill=stat(x)或之外的其他东西控制的示例fill=stat(y)

我不太了解这项fill=stat业务,无法在这方面取得进展。有谁知道通过第三个变量完成着色的例子?

任何帮助表示赞赏。

4

0 回答 0