我正在尝试从具有三个变量的数据中绘制热图。我正在将ggplot与geom_raster一起使用,但似乎不起作用。我看不到出什么问题了。
library(tidyverse)
p <- read.csv("Rheatmaptest.csv", header = TRUE);
p
xdir ydir Category.1 Category.2 Category.3 Category.4
1 -10.731 10.153 0.61975 3.2650 0.19025 13.00
2 -21.462 9.847 1.77000 3.2475 0.56325 16.70
3 -32.193 9.847 1.65500 2.9900 0.51325 176.00
4 -42.924 10.000 1.34500 3.1800 0.41350 177.00
5 -16.770 20.000 0.69600 3.4975 0.22150 174.00
6 -33.541 20.000 0.68700 3.4275 0.20250 4.24
7 -50.311 20.000 0.77350 3.1575 0.24250 177.00
8 -67.082 20.000 1.09600 3.5350 0.34600 163.00
9 -18.689 30.000 0.54250 3.5875 0.18100 160.00
10 -37.378 30.000 0.63075 3.7125 0.19300 158.00
11 -56.067 30.000 0.71975 3.5425 0.22225 2.26
12 -74.756 30.000 0.79100 3.3750 0.23000 8.24
13 -20.000 40.000 0.76650 3.7200 0.24375 167.00
14 -40.000 40.000 0.68325 3.5300 0.21350 155.00
15 -60.000 40.000 0.81075 3.3400 0.25325 145.00
16 -80.000 40.000 0.68800 3.6375 0.21350 146.00
17 -19.521 50.000 0.67900 3.7150 0.21700 167.00
18 -39.043 50.000 0.69500 3.7950 0.21225 109.00
19 -58.564 49.847 0.68300 3.5575 0.20700 166.00
20 -78.085 50.000 0.67375 3.5325 0.21975 163.00
21 -17.562 60.000 0.64350 3.7025 0.19475 140.00
22 -35.585 60.000 0.56650 3.5250 0.17775 34.30
23 -54.067 60.000 0.82350 3.7700 0.24525 129.00
24 -72.090 60.000 0.85450 3.6675 0.28225 156.00
25 -15.522 70.000 0.59100 3.3475 0.18875 144.00
26 -31.044 69.847 0.56200 3.7975 0.17250 159.00
27 -46.566 70.000 0.79375 3.5350 0.24975 145.00
28 -62.088 70.000 0.64275 3.6100 0.20375 132.00
29 -11.040 80.000 0.75875 3.7450 0.23925 138.00
30 -22.081 80.000 0.81900 3.3875 0.25975 144.00
31 -33.121 80.000 0.72725 3.5825 0.22175 132.00
32 -44.161 80.000 0.83300 3.5550 0.27000 177.00
33 -4.522 90.000 1.77500 3.1250 0.57200 16.30
34 -9.440 90.000 0.96925 3.7200 0.31000 163.00
35 -13.106 90.000 0.76975 3.6600 0.23800 3.50
36 -18.089 90.000 0.86050 3.6750 0.26650 80.50
ggplot(p, aes(x = xdir, y = ydir)) +
geom_raster(aes(fill = Category.1), interpolate = TRUE) +
scale_fill_gradient2(limits=c(0.5,2), low="blue", mid="yellow", high="red", midpoint=1)
使用geom_point而不是geom_raster时,我可以看到点。即使使用geom_raster,我也只能在相应位置看到很小的点。插值似乎无效。
我想念什么吗?
答案 0 :(得分:0)