下图中使用的主题是什么,或者可以使用什么类似的主题来创建一个像所提供的照片中的吸引人的图表?我在互联网上看到了照片,但没有给出代码。我已经获得了代码,但很难用当前的主题来解释。
如上图所示,每个week
和age
组合都有一个separate box
。很容易判断出某个年龄组在特定一周内的新冠病毒数量。有人能告诉下面的主题是什么吗?或者建议一个类似的主题来改善科学观众的图形外观?
这里是我的数据的可重复的例子
df <- structure(
list(
total_count = c(
10L,
0L,
15L,
0L,
20L,
0L,
0L,
50L,
0L,
6L,
1L,
10L,
7L,
0L,
0L,
29L,
0L,
2L,
11L,
3L,
0L,
12L,
0L,
30L,
0L,
0L,
29L,
44L,
10L,
5L,
2L,
145L,
0L,
70L
),
mean_temp = c(
18.87,
18.87,
18.87,
18.87,
18.87,
18.87,
18.87,
18.87,
18.87,
21.85,
21.85,
21.85,
21.85,
21.85,
21.85,
21.85,
21.85,
21.85,
17.11,
17.11,
17.11,
17.11,
17.11,
17.11,
17.11,
17.11,
18.82,
18.82,
18.82,
18.82,
18.82,
18.82,
18.82,
18.82
),
lwd_duration = c(
64.32,
64.32,
64.32,
64.32,
64.32,
64.32,
64.32,
64.32,
64.32,
104.2,
104.2,
104.2,
104.2,
104.2,
104.2,
104.2,
104.2,
104.2,
53.53,
53.53,
53.53,
53.53,
53.53,
53.53,
53.53,
53.53,
60.43,
60.43,
60.43,
60.43,
60.43,
60.43,
60.43,
60.43
)
),
row.names = c(NA,-34L),
class = c("tbl_df", "tbl", "data.frame"),
na.action = structure(
c(
`4` = 4L,
`5` = 5L,
`6` = 6L,
`7` = 7L,
`8` = 8L,
`9` = 9L,
`78` = 78L,
`87` = 87L,
`96` = 96L,
`105` = 105L,
`114` = 114L,
`123` = 123L,
`132` = 132L,
`141` = 141L,
`150` = 150L,
`159` = 159L,
`168` = 168L,
`177` = 177L,
`186` = 186L,
`849` = 849L,
`850` = 850L,
`851` = 851L,
`852` = 852L,
`891` = 891L,
`892` = 892L,
`893` = 893L,
`894` = 894L,
`921` = 921L,
`922` = 922L,
`923` = 923L,
`924` = 924L,
`937` = 937L,
`938` = 938L,
`939` = 939L,
`940` = 940L,
`969` = 969L,
`970` = 970L,
`971` = 971L,
`972` = 972L,
`985` = 985L,
`986` = 986L,
`987` = 987L,
`988` = 988L,
`1017` = 1017L,
`1018` = 1018L,
`1019` = 1019L,
`1020` = 1020L,
`1033` = 1033L,
`1034` = 1034L,
`1035` = 1035L,
`1036` = 1036L
),
class = "omit"
)
)
用于生成图形的代码:
dat2 <-
df %>%
as_tibble() %>%
mutate(
mean_temp = cut_interval(mean_temp, n = 10),
total_count = cut_interval(total_count, n = 10),
) %>%
group_by(mean_temp, total_count) %>%
summarize(lwd_duration = mean(lwd_duration))
#> `summarise()` has grouped output by 'mean_temp'. You can override using the
#> `.groups` argument.
ggplot(dat2, aes(mean_temp, total_count)) +
geom_tile(aes(fill = lwd_duration)) +
geom_text(aes(label = round(lwd_duration, 1))) +
scale_fill_gradient(low = "white", high = "red")
在我的图中,我应该有一个单独的框,用于mean_temp
[17.17,17.6]和total_count
[0,14.5]组合,框内有total_count
53.5。所以很难解释。我不想让单独的框重叠。我在每个单元格中有多个观察结果。假设对于一个特定的mean_temp
范围和一个total_count
范围,我有5,15,100的值,所以我必须使用平均数。感谢您的帮助。
1条答案
按热度按时间stszievb1#
创建于2023-04-19带有reprex v2.0.2