I saw this photo of a heatmap on the internet, but no code was given.
I'd like to make the same heatmap for my data. My data looks like this.
I want the variable mean_temp
on the x-axis, total_count
on the y-axis, and I want the boxes in the heatmap to be filled with the values of lwd_duration
. Here is a reproducible example of my data
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"
)
)
Could someone help with the code to create the above heatmap for my data? Thank you!