我正在尝试使用 ggplot 创建热图。我正在使用以下代码:
ggplot(ff, aes(x=Days, y=variable)) +
geom_tile(aes(fill=value),colour="blue") +
scale_fill_gradient(limits=c(-1,1),low="blue",high="red",na.value="white")
以下是我的问题:
- 如何操作 geom_tile 中的比例单位(这样不是每 0.2 创建一次热图,而是使用每 0.1 或 0.05 的步长)
- 是否可以使用我使用的更丰富的颜色模式(例如一些预定义的颜色模式,如热图函数
- 我的数据框中有 NA 渲染为白色。有没有更好的方法来处理 NA 并使其透明化?
数据ff如下:
Days variable value
1 4 Short.Range.Days..2 -0.81747353
2 6 Short.Range.Days..2 -0.548692305
3 8 Short.Range.Days..2 -0.344287337
4 10 Short.Range.Days..2 -0.214313697
5 12 Short.Range.Days..2 -0.166991021
6 14 Short.Range.Days..2 -0.087645101
7 16 Short.Range.Days..2 0.003306877
8 18 Short.Range.Days..2 0.014363975
9 20 Short.Range.Days..2 0.022512668
10 22 Short.Range.Days..2 0.040381662
11 24 Short.Range.Days..2 0.062312058
12 26 Short.Range.Days..2 0.079032057
13 28 Short.Range.Days..2 0.062894323
14 30 Short.Range.Days..2 0.042261172
15 32 Short.Range.Days..2 0.032980453
16 34 Short.Range.Days..2 0.040095505
17 36 Short.Range.Days..2 0.039992051
18 38 Short.Range.Days..2 0.006244882
19 40 Short.Range.Days..2 -0.005749414
20 42 Short.Range.Days..2 -0.008062039
21 44 Short.Range.Days..2 -0.023538994
22 46 Short.Range.Days..2 0.000465245
23 48 Short.Range.Days..2 0.011341621
24 50 Short.Range.Days..2 0.031610377
25 52 Short.Range.Days..2 0.043711238
26 54 Short.Range.Days..2 0.052674899
27 56 Short.Range.Days..2 0.052963846
28 58 Short.Range.Days..2 0.042461133
29 60 Short.Range.Days..2 0.041458926
30 4 Short.Range.Days..4 NA
31 6 Short.Range.Days..4 -0.564954032
32 8 Short.Range.Days..4 -0.376387471
33 10 Short.Range.Days..4 -0.212740266
34 12 Short.Range.Days..4 -0.107961718
35 14 Short.Range.Days..4 -0.072863517
36 16 Short.Range.Days..4 -0.013560192
37 18 Short.Range.Days..4 -0.014244693
38 20 Short.Range.Days..4 0.003714455
39 22 Short.Range.Days..4 0.018009887
40 24 Short.Range.Days..4 0.038299314
41 26 Short.Range.Days..4 0.048826919
42 28 Short.Range.Days..4 0.042215816
43 30 Short.Range.Days..4 0.026936439
44 32 Short.Range.Days..4 0.015311212
45 34 Short.Range.Days..4 0.024097239
46 36 Short.Range.Days..4 -0.004329243
47 38 Short.Range.Days..4 -0.001842634
48 40 Short.Range.Days..4 0.000926598
49 42 Short.Range.Days..4 -0.011272775
50 44 Short.Range.Days..4 -0.009693908
51 46 Short.Range.Days..4 -0.001668079
52 48 Short.Range.Days..4 0.016156964
53 50 Short.Range.Days..4 0.042374732
54 52 Short.Range.Days..4 0.046776012
55 54 Short.Range.Days..4 0.045923267
56 56 Short.Range.Days..4 0.050384377
57 58 Short.Range.Days..4 0.045215707
58 60 Short.Range.Days..4 0.047902343
59 4 Short.Range.Days..6 NA
60 6 Short.Range.Days..6 NA
61 8 Short.Range.Days..6 -0.441329726
62 10 Short.Range.Days..6 -0.238801239
63 12 Short.Range.Days..6 -0.15476164
64 14 Short.Range.Days..6 -0.059414124
65 16 Short.Range.Days..6 -0.061674965
66 18 Short.Range.Days..6 -0.025409294
67 20 Short.Range.Days..6 -0.009152774
68 22 Short.Range.Days..6 -0.001703372
69 24 Short.Range.Days..6 -0.000247112
70 26 Short.Range.Days..6 0.0253183
71 28 Short.Range.Days..6 0.039929109
72 30 Short.Range.Days..6 -0.001386462
73 32 Short.Range.Days..6 0.008182091
74 34 Short.Range.Days..6 0.029240807
75 36 Short.Range.Days..6 -0.002854685
76 38 Short.Range.Days..6 -0.007379733
77 40 Short.Range.Days..6 -0.004630816
78 42 Short.Range.Days..6 -0.011870576
79 44 Short.Range.Days..6 -0.015306308
80 46 Short.Range.Days..6 -0.005366024
81 48 Short.Range.Days..6 0.006607034
82 50 Short.Range.Days..6 0.018644749
83 52 Short.Range.Days..6 0.026165148
84 54 Short.Range.Days..6 0.036606456
85 56 Short.Range.Days..6 0.048953922
86 58 Short.Range.Days..6 0.043359266
87 60 Short.Range.Days..6 0.038203532
88 4 Short.Range.Days..8 NA
89 6 Short.Range.Days..8 NA
90 8 Short.Range.Days..8 NA
91 10 Short.Range.Days..8 -0.381950109
92 12 Short.Range.Days..8 -0.218592498
93 14 Short.Range.Days..8 -0.101448266
94 16 Short.Range.Days..8 -0.046656489
95 18 Short.Range.Days..8 -0.042095639
96 20 Short.Range.Days..8 -0.026922636
97 22 Short.Range.Days..8 -0.015991528
98 24 Short.Range.Days..8 -0.011757444
99 26 Short.Range.Days..8 0.007997248
100 28 Short.Range.Days..8 0.036514373
101 30 Short.Range.Days..8 0.006496822
102 32 Short.Range.Days..8 -0.004494976
103 34 Short.Range.Days..8 0.013963243
104 36 Short.Range.Days..8 0.022236117
105 38 Short.Range.Days..8 0.040222229
106 40 Short.Range.Days..8 0.024015061
107 42 Short.Range.Days..8 0.014655371
108 44 Short.Range.Days..8 -0.003435171
109 46 Short.Range.Days..8 0.004921792
110 48 Short.Range.Days..8 0.025002607
111 50 Short.Range.Days..8 0.039823008
112 52 Short.Range.Days..8 0.028497197
113 54 Short.Range.Days..8 0.033465104
114 56 Short.Range.Days..8 0.037187076
115 58 Short.Range.Days..8 0.035133715
116 60 Short.Range.Days..8 0.044956739
117 4 Short.Range.Days..10 NA
118 6 Short.Range.Days..10 NA
119 8 Short.Range.Days..10 NA
120 10 Short.Range.Days..10 NA
121 12 Short.Range.Days..10 -0.315010077
122 14 Short.Range.Days..10 -0.159081521
123 16 Short.Range.Days..10 -0.071303675
124 18 Short.Range.Days..10 -0.084264406
125 20 Short.Range.Days..10 -0.055602557
126 22 Short.Range.Days..10 -0.015130798
127 24 Short.Range.Days..10 0.005610983
128 26 Short.Range.Days..10 0.009360452
129 28 Short.Range.Days..10 0.00674219
130 30 Short.Range.Days..10 0.002157462
131 32 Short.Range.Days..10 0.00349763
132 34 Short.Range.Days..10 -0.001412894
133 36 Short.Range.Days..10 0.003717493
134 38 Short.Range.Days..10 0.002120068
135 40 Short.Range.Days..10 0.006367466
136 42 Short.Range.Days..10 -0.000411258
137 44 Short.Range.Days..10 0.012566411
138 46 Short.Range.Days..10 0.014464965
139 48 Short.Range.Days..10 0.031026233
140 50 Short.Range.Days..10 0.04388952
141 52 Short.Range.Days..10 0.042532374
142 54 Short.Range.Days..10 0.06035085
143 56 Short.Range.Days..10 0.054378445
144 58 Short.Range.Days..10 0.05048477
145 60 Short.Range.Days..10 0.064256151
146 4 Short.Range.Days..12 NA
147 6 Short.Range.Days..12 NA
148 8 Short.Range.Days..12 NA
149 10 Short.Range.Days..12 NA
150 12 Short.Range.Days..12 NA
151 14 Short.Range.Days..12 -0.227372691
152 16 Short.Range.Days..12 -0.156908358
153 18 Short.Range.Days..12 -0.097853165
154 20 Short.Range.Days..12 -0.031213742
155 22 Short.Range.Days..12 -0.002203366
156 24 Short.Range.Days..12 0.027172361
157 26 Short.Range.Days..12 -0.002829266
158 28 Short.Range.Days..12 0.003026913
159 30 Short.Range.Days..12 0.005941515
160 32 Short.Range.Days..12 0.005652349
161 34 Short.Range.Days..12 0.005849875
162 36 Short.Range.Days..12 0.008607215
163 38 Short.Range.Days..12 -0.008046473
164 40 Short.Range.Days..12 -0.003125555
165 42 Short.Range.Days..12 0.018868117
166 44 Short.Range.Days..12 0.017476927
167 46 Short.Range.Days..12 0.011919605
168 48 Short.Range.Days..12 0.021178085
169 50 Short.Range.Days..12 0.041199466
170 52 Short.Range.Days..12 0.034283292
171 54 Short.Range.Days..12 0.029778266
172 56 Short.Range.Days..12 0.039525157
173 58 Short.Range.Days..12 0.046134386
174 60 Short.Range.Days..12 0.065925521
175 4 Short.Range.Days..14 NA
176 6 Short.Range.Days..14 NA
177 8 Short.Range.Days..14 NA
178 10 Short.Range.Days..14 NA
179 12 Short.Range.Days..14 NA
180 14 Short.Range.Days..14 NA
181 16 Short.Range.Days..14 -0.261691083
182 18 Short.Range.Days..14 -0.142068675
183 20 Short.Range.Days..14 -0.074500031
184 22 Short.Range.Days..14 -0.012082714
185 24 Short.Range.Days..14 0.005659554
186 26 Short.Range.Days..14 0.012468794
187 28 Short.Range.Days..14 -0.002796818
188 30 Short.Range.Days..14 -0.007217387
189 32 Short.Range.Days..14 -0.011216542
190 34 Short.Range.Days..14 -0.012975914
191 36 Short.Range.Days..14 0.001431991
192 38 Short.Range.Days..14 -0.016442151
193 40 Short.Range.Days..14 -0.028879887
194 42 Short.Range.Days..14 -0.008744675
195 44 Short.Range.Days..14 0.003396965
196 46 Short.Range.Days..14 0.006496634
197 48 Short.Range.Days..14 0.034291641
198 50 Short.Range.Days..14 0.037316392
199 52 Short.Range.Days..14 0.025819292
200 54 Short.Range.Days..14 0.017700215
201 56 Short.Range.Days..14 0.030761449
202 58 Short.Range.Days..14 0.042412907
203 60 Short.Range.Days..14 0.064320329
204 4 Short.Range.Days..16 NA
205 6 Short.Range.Days..16 NA
206 8 Short.Range.Days..16 NA
207 10 Short.Range.Days..16 NA
208 12 Short.Range.Days..16 NA
209 14 Short.Range.Days..16 NA
210 16 Short.Range.Days..16 NA
211 18 Short.Range.Days..16 -0.24576188
212 20 Short.Range.Days..16 -0.124836183
213 22 Short.Range.Days..16 -0.048221263
214 24 Short.Range.Days..16 -0.035029068
215 26 Short.Range.Days..16 -0.017987078
216 28 Short.Range.Days..16 -0.008633172
217 30 Short.Range.Days..16 -0.031737817
218 32 Short.Range.Days..16 -0.0329801
219 34 Short.Range.Days..16 -0.022857234
220 36 Short.Range.Days..16 -0.033276605
221 38 Short.Range.Days..16 -0.041135562
222 40 Short.Range.Days..16 -0.040310448
223 42 Short.Range.Days..16 -0.039212637
224 44 Short.Range.Days..16 -0.022545529
225 46 Short.Range.Days..16 -0.003491653
226 48 Short.Range.Days..16 0.019354126
227 50 Short.Range.Days..16 0.01404553
228 52 Short.Range.Days..16 0.009496747
229 54 Short.Range.Days..16 0.021609426
230 56 Short.Range.Days..16 0.053664294
231 58 Short.Range.Days..16 0.034393419
232 60 Short.Range.Days..16 0.051344379
233 4 Short.Range.Days..18 NA
234 6 Short.Range.Days..18 NA
235 8 Short.Range.Days..18 NA
236 10 Short.Range.Days..18 NA
237 12 Short.Range.Days..18 NA
238 14 Short.Range.Days..18 NA
239 16 Short.Range.Days..18 NA
240 18 Short.Range.Days..18 NA
241 20 Short.Range.Days..18 -0.201415281
242 22 Short.Range.Days..18 -0.094650643
243 24 Short.Range.Days..18 -0.050407965
244 26 Short.Range.Days..18 -0.011944599
245 28 Short.Range.Days..18 0.006048385
246 30 Short.Range.Days..18 -0.009465899
247 32 Short.Range.Days..18 -0.010465794
248 34 Short.Range.Days..18 -0.017793544
249 36 Short.Range.Days..18 -0.043409233
250 38 Short.Range.Days..18 -0.047284525
251 40 Short.Range.Days..18 -0.034924265
252 42 Short.Range.Days..18 -0.035220327
253 44 Short.Range.Days..18 -0.038604807
254 46 Short.Range.Days..18 -0.017079637
255 48 Short.Range.Days..18 0.016028302
256 50 Short.Range.Days..18 0.012447745
257 52 Short.Range.Days..18 0.030016509
258 54 Short.Range.Days..18 0.047367639
259 56 Short.Range.Days..18 0.050529707
260 58 Short.Range.Days..18 0.043451669
261 60 Short.Range.Days..18 0.057382559
262 4 Short.Range.Days..20 NA
263 6 Short.Range.Days..20 NA
264 8 Short.Range.Days..20 NA
265 10 Short.Range.Days..20 NA
266 12 Short.Range.Days..20 NA
267 14 Short.Range.Days..20 NA
268 16 Short.Range.Days..20 NA
269 18 Short.Range.Days..20 NA
270 20 Short.Range.Days..20 NA
271 22 Short.Range.Days..20 -0.150659349
272 24 Short.Range.Days..20 -0.087423089
273 26 Short.Range.Days..20 -0.038100588
274 28 Short.Range.Days..20 -0.046059396
275 30 Short.Range.Days..20 -0.049492703
276 32 Short.Range.Days..20 -0.025327689
277 34 Short.Range.Days..20 -0.027303766
278 36 Short.Range.Days..20 -0.029267308
279 38 Short.Range.Days..20 -0.030914711
280 40 Short.Range.Days..20 -0.020236697
281 42 Short.Range.Days..20 -0.020736933
282 44 Short.Range.Days..20 -0.021439136
283 46 Short.Range.Days..20 -0.010624047
284 48 Short.Range.Days..20 0.016708851
285 50 Short.Range.Days..20 0.031313822
286 52 Short.Range.Days..20 0.041814604
287 54 Short.Range.Days..20 0.041267541
288 56 Short.Range.Days..20 0.057323017
289 58 Short.Range.Days..20 0.041221109
290 60 Short.Range.Days..20 0.05872252
291 4 Short.Range.Days..22 NA
292 6 Short.Range.Days..22 NA
293 8 Short.Range.Days..22 NA
294 10 Short.Range.Days..22 NA
295 12 Short.Range.Days..22 NA
296 14 Short.Range.Days..22 NA
297 16 Short.Range.Days..22 NA
298 18 Short.Range.Days..22 NA
299 20 Short.Range.Days..22 NA
300 22 Short.Range.Days..22 NA
301 24 Short.Range.Days..22 -0.15090012
302 26 Short.Range.Days..22 -0.104523303
303 28 Short.Range.Days..22 -0.092845968
304 30 Short.Range.Days..22 -0.083648125
305 32 Short.Range.Days..22 -0.046778288
306 34 Short.Range.Days..22 -0.058309377
307 36 Short.Range.Days..22 -0.045664863
308 38 Short.Range.Days..22 -0.015971201
309 40 Short.Range.Days..22 -0.0296146
310 42 Short.Range.Days..22 -0.013281189
311 44 Short.Range.Days..22 -0.014848272
312 46 Short.Range.Days..22 -0.011940442
313 48 Short.Range.Days..22 0.021530103
314 50 Short.Range.Days..22 0.031175715
315 52 Short.Range.Days..22 0.024433409
316 54 Short.Range.Days..22 0.033544534
317 56 Short.Range.Days..22 0.022443897
318 58 Short.Range.Days..22 0.025883639
319 60 Short.Range.Days..22 0.038383722
320 4 Short.Range.Days..24 NA
321 6 Short.Range.Days..24 NA
322 8 Short.Range.Days..24 NA
323 10 Short.Range.Days..24 NA
324 12 Short.Range.Days..24 NA
325 14 Short.Range.Days..24 NA
326 16 Short.Range.Days..24 NA
327 18 Short.Range.Days..24 NA
328 20 Short.Range.Days..24 NA
329 22 Short.Range.Days..24 NA
330 24 Short.Range.Days..24 NA
331 26 Short.Range.Days..24 -0.219027869
332 28 Short.Range.Days..24 -0.161214748
333 30 Short.Range.Days..24 -0.13408164
334 32 Short.Range.Days..24 -0.08070956
335 34 Short.Range.Days..24 -0.082899097
336 36 Short.Range.Days..24 -0.062595752
337 38 Short.Range.Days..24 -0.024198995
338 40 Short.Range.Days..24 -0.004691925
339 42 Short.Range.Days..24 -0.014496501
340 44 Short.Range.Days..24 -0.022884719
341 46 Short.Range.Days..24 -0.014154586
342 48 Short.Range.Days..24 0.000281776
343 50 Short.Range.Days..24 0.0071921
344 52 Short.Range.Days..24 -0.001297935
345 54 Short.Range.Days..24 -0.0015083
346 56 Short.Range.Days..24 -0.004905885
347 58 Short.Range.Days..24 0.001062168
348 60 Short.Range.Days..24 0.016119001
349 4 Short.Range.Days..26 NA
350 6 Short.Range.Days..26 NA
351 8 Short.Range.Days..26 NA
352 10 Short.Range.Days..26 NA
353 12 Short.Range.Days..26 NA
354 14 Short.Range.Days..26 NA
355 16 Short.Range.Days..26 NA
356 18 Short.Range.Days..26 NA
357 20 Short.Range.Days..26 NA
358 22 Short.Range.Days..26 NA
359 24 Short.Range.Days..26 NA
360 26 Short.Range.Days..26 NA
361 28 Short.Range.Days..26 -0.243817468
362 30 Short.Range.Days..26 -0.175056647
363 32 Short.Range.Days..26 -0.118290191
364 34 Short.Range.Days..26 -0.077769693
365 36 Short.Range.Days..26 -0.026417708
366 38 Short.Range.Days..26 -0.016489546
367 40 Short.Range.Days..26 -0.012463804
368 42 Short.Range.Days..26 -0.008863066
369 44 Short.Range.Days..26 -0.017249374
370 46 Short.Range.Days..26 -0.016538643
371 48 Short.Range.Days..26 -0.004546857
372 50 Short.Range.Days..26 -0.003654304
373 52 Short.Range.Days..26 -0.002765445
374 54 Short.Range.Days..26 -0.003328998
375 56 Short.Range.Days..26 -0.00821013
376 58 Short.Range.Days..26 0.002902259
377 60 Short.Range.Days..26 0.005409932
378 4 Short.Range.Days..28 NA
379 6 Short.Range.Days..28 NA
380 8 Short.Range.Days..28 NA
381 10 Short.Range.Days..28 NA
382 12 Short.Range.Days..28 NA
383 14 Short.Range.Days..28 NA
384 16 Short.Range.Days..28 NA
385 18 Short.Range.Days..28 NA
386 20 Short.Range.Days..28 NA
387 22 Short.Range.Days..28 NA
388 24 Short.Range.Days..28 NA
389 26 Short.Range.Days..28 NA
390 28 Short.Range.Days..28 NA
391 30 Short.Range.Days..28 -0.2017481
392 32 Short.Range.Days..28 -0.134879691
393 34 Short.Range.Days..28 -0.062318376
394 36 Short.Range.Days..28 -0.034419214
395 38 Short.Range.Days..28 -0.017322394
396 40 Short.Range.Days..28 -0.029575546
397 42 Short.Range.Days..28 -0.023687556
398 44 Short.Range.Days..28 -0.012397918
399 46 Short.Range.Days..28 -0.009062897
400 48 Short.Range.Days..28 -0.011838491
401 50 Short.Range.Days..28 -0.012319173
402 52 Short.Range.Days..28 -0.00739976
403 54 Short.Range.Days..28 -0.009963764
404 56 Short.Range.Days..28 -0.013427471
405 58 Short.Range.Days..28 -0.016496869
406 60 Short.Range.Days..28 -0.007558199
407 4 Short.Range.Days..30 NA
408 6 Short.Range.Days..30 NA
409 8 Short.Range.Days..30 NA
410 10 Short.Range.Days..30 NA
411 12 Short.Range.Days..30 NA
412 14 Short.Range.Days..30 NA
413 16 Short.Range.Days..30 NA
414 18 Short.Range.Days..30 NA
415 20 Short.Range.Days..30 NA
416 22 Short.Range.Days..30 NA
417 24 Short.Range.Days..30 NA
418 26 Short.Range.Days..30 NA
419 28 Short.Range.Days..30 NA
420 30 Short.Range.Days..30 NA
421 32 Short.Range.Days..30 -0.181026029
422 34 Short.Range.Days..30 -0.089303464
423 36 Short.Range.Days..30 -0.04590373
424 38 Short.Range.Days..30 -0.048539444
425 40 Short.Range.Days..30 -0.053611014
426 42 Short.Range.Days..30 -0.029848611
427 44 Short.Range.Days..30 -0.038913148
428 46 Short.Range.Days..30 -0.035174622
429 48 Short.Range.Days..30 -0.025815231
430 50 Short.Range.Days..30 -0.025238126
431 52 Short.Range.Days..30 -0.019484408
432 54 Short.Range.Days..30 -0.026327212
433 56 Short.Range.Days..30 -0.027493418
434 58 Short.Range.Days..30 -0.036467761
435 60 Short.Range.Days..30 0.003688413