首页 > 解决方案 > 更改热图的比例以显示更多颜色

问题描述

我目前有类似于下面的数据,可能有更精细的网格。我想知道是否有可能使网格ggplot heatmap更精细?意思是为不同的值提供更多的颜色z。截至目前,我当前的情节主要是 1 颜色,因为它们都在1e-2和之间1e-5,但我有一个值,1e-13似乎根本看不到它。

x <- seq(3, 5, by = 1)
y <- seq(5, 101, by = 2)
z <- seq(3, 10^-13, length = 146)
### Combinations
combinations <- expand_grid(x, y) %>%
  subset(y > x) %>%
  cbind(z) %>%
  as.matrix()

combinations %>%
  ggplot(aes(x = x, y = y)) +
  geom_tile(aes(fill = z))

提前致谢。

标签: rggplot2heatmap

解决方案


或者是关于它的?

x <- seq(3, 5, by = 1)
y <- seq(5, 101, by = 2)
z <- seq(3, 10^-13, length = 146)

combinations <- expand_grid(x, y) %>%
  subset(y > x) %>%
  cbind(z)

combinations %>%
  ggplot(aes(x, y, z=z)) +
  geom_contour_filled()+
  geom_point(data = combinations %>% filter(z<1e-6),
             size=10, color = "red")

这样做。它必须工作!

library(tidyverse)
library(ggplot2)

x <- seq(3, 5, by = 1)
y <- seq(5, 101, by = 2)
z <- seq(3, 10^-13, length = 146)

combinations <- expand_grid(x, y) %>%
  subset(y > x) %>%
  cbind(z)

combinations %>%
  ggplot(aes(x, y, z=z)) +
  geom_contour_filled()+
  geom_point(data = combinations %>% dplyr::filter(z<1e-6),
             size=10, color = "red")


推荐阅读