r - facet_wrap() + ggplot2() 中每个面的独立颜色渐变

标签 r ggplot2 colors gradient facet-wrap

我正在努力为 facet_wrap() 中的每个方面绘制渐变色标独立。
数据太大,无法在此处发布,但这是我的代码:

ggplot(stack, aes(hour, day)) + 
  geom_tile(aes(fill = percent), colour = "white") + 
  facet_wrap(~author, ncol = 3) +
  theme_minimal() +
  scale_fill_distiller(palette = 'RdYlBu') +
  theme(
    axis.title.x = element_blank(), axis.title.y = element_blank(),
    legend.position = "none",
    strip.background = element_rect(fill = '#E5E6E1'),
    strip.text = element_text(face = 'bold')
  )

enter image description here

但是,如果我只单独绘制一位作者,我会得到:

enter image description here

我只想用自己的渐变色标绘制每个方面,而不是与其他方面共享。应该很简单,但我没能做到。我尝试添加 group = authoraes()geom_tile()ggplot()但它不起作用。

最佳答案

经过大量研究,我最终使用了提供的解决方案 here使用 gridExtra .我想没有简单的方法可以只使用 ggplot .

关于r - facet_wrap() + ggplot2() 中每个面的独立颜色渐变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59108493/

相关文章:

r - 将列表的内容写入 R 中的一个文件

r - 将不同列表的子列表组合成数据框列表

r - 在 ggplot2 中,如何将堆叠直方图中的小值条形组合在一起?

c++ - 如何在使用 OpenCV 遍历像素时添加 2 个 Mat 像素值?

colors - 使用 C++ 更改 Xlib 窗口背景颜色

javascript - 使用 for 循环动态更改 Div 颜色

javascript - r2d3:d3.js 条形图在调整大小时消失

r - 使用RStudio中deSolve包中的dede来求解时滞ODE

r - R plot() 或 ggplot2() 中的对数 y 轴刻度线

r - 如何使用 ggplot 函数添加到 cnetplot?