0

我希望通过添加带有标记区域的框和穿过 x 和 y 轴的截距来指定该图中的区域,我使用 ggplot2 为数据生成了这些区域在此处输入链接描述

p <- ggplot(data, aes(Res1,Res2,fill=Val)) +
  geom_tile() + 
  scale_fill_gradient(low="white", high="blue") +
  theme_bw() + 
  labs(x="Residue", y="Residue") +
  theme(axis.text.y = element_text(face="bold",size=11), 
        panel.background = element_blank(), 
        legend.position="bottom", 
        axis.title=element_text(face="bold",size=14), 
        axis.ticks=element_blank(), 
        panel.grid.minor=element_blank(), 
        panel.grid.major=element_blank(), 
        axis.text.x = element_text(face="bold",size=11)) + 
  scale_colour_hue(l=40) + 
  scale_x_continuous(expand=c(0,0))

在此处输入图像描述

区域为 [1:5=M1; 6:11=M2;12:15=M3;16:30=M4] I. 一种方法是在我尝试使用 geom_rect 命令的轴的末尾添加块,但我总是发现一个或其他错误。我尝试了以下方法:

Df <- data.frame(x1=c(1,6,12,16), 
                 x2=c(5,11,15,30), 
                 t=c("M1", "M2", "M3", "M4"))
p +  geom_rect(data=Df, 
               aes(xmin=x1,xmax=x2,ymax=1,ymin=2,fill=t)) + 
  scale_fill_manual(values=c("red", "blue", "green", "black"))

我收到如下错误:如果我尝试更改比例,则将连续缩放为离散,反之亦然。如果我将 Df 中的 y1,y2 值指定为 y1=c(1,1,1,1) 和 y2=c(2,2,2,2)。我收到以下错误:美学长度必须为 1,或与 dataProblems 长度相同。我可能对 geom_rect 做错了,因为这是我第一次使用。我希望在 x 轴的末尾指定框(如果低于 y=1,它会更好,因为它不会隐藏实际的图)和 y2 轴的右侧,然后绘制 xintercept 和 yintercept。

二、如果我暂时忘记 geom_rect 并尝试使用截距作为标记,例如以下代码:

p <- ggplot(data=mydata, aes(Res1,Res2,fill=Val)) + 
  geom_tile() + 
  scale_fill_gradient2(low="red", high="blue") + 
  theme_bw() +
  labs(x="Residue", y="Residue") +
  theme(axis.text.y = element_text(face="bold",size=11), 
        panel.background =element_blank(), 
        legend.position="bottom", 
        axis.title=element_text(face="bold",size=14), 
        axis.ticks=element_blank(), 
        panel.grid.minor=element_blank(), 
        panel.grid.major=element_blank(),
        axis.text.x = element_text(face="bold",size=11)) + 
  scale_colour_hue(l=40)  +
  scale_x_continuous(expand=c(0,0)) + 
  scale_y_continuous(expand=c(0,0)) +
  geom_vline(aes(xintercept=Dom1), linetype="solid", colour="black", size=0.7)+
  geom_hline(aes(yintercept=Dom2), linetype="solid", colour="black", size=0.7)

我收到错误消息:错误:提供给连续刻度的离散值。我知道我在这里遗漏了一些东西。但我看不到什么。我对 R 的了解不是很好,但我喜欢它的分析和绘图,并希望发现更多。可能还有其他更简单的方法来绘制此类图。任何帮助表示赞赏!

4

1 回答 1

0

我会内联你的数据

data <- read.csv(text=
"Dom1,Res1,Dom2,Res2,Val
M1,1,M1,1,1
M1,1,M1,2,0.96978
M1,1,M1,3,0.961
M1,1,M1,4,0.95495
M1,1,M1,5,0.9525
M1,1,M2,6,0.94745
M1,1,M2,7,0.9439
M1,1,M2,8,0.93963
M1,1,M2,9,0.92747
M1,1,M2,10,0.93275
M1,1,M2,11,0.93267
M1,1,M3,12,0.91837
M1,1,M3,13,0.90537
M1,1,M3,14,0.90913
M1,1,M3,15,0.8998
M1,1,M4,16,0.86228
M1,1,M4,17,0.82022
M1,1,M4,18,0.81726
M1,1,M4,19,0.74939
M1,1,M4,20,0.70877
M1,1,M4,21,0.69285
M1,1,M4,22,0.76588
M1,1,M4,23,0.80563
M1,1,M4,24,0.86017
M1,1,M4,25,0.88171
M1,1,M4,26,0.91169
M1,1,M4,27,0.91854
M1,1,M4,28,0.92305
M1,1,M4,29,0.91976
M1,1,M4,30,0.89547
M1,2,M1,1,0.96978
M1,2,M1,2,1
M1,2,M1,3,0.98903
M1,2,M1,4,0.98303
M1,2,M1,5,0.98538
M1,2,M2,6,0.97958
M1,2,M2,7,0.96968
M1,2,M2,8,0.96762
M1,2,M2,9,0.95869
M1,2,M2,10,0.95757
M1,2,M2,11,0.95369
M1,2,M3,12,0.94539
M1,2,M3,13,0.93139
M1,2,M3,14,0.9261
M1,2,M3,15,0.9172
M1,2,M4,16,0.87634
M1,2,M4,17,0.83872
M1,2,M4,18,0.84047
M1,2,M4,19,0.77153
M1,2,M4,20,0.7397
M1,2,M4,21,0.7247
M1,2,M4,22,0.79714
M1,2,M4,23,0.84296
M1,2,M4,24,0.89441
M1,2,M4,25,0.91888
M1,2,M4,26,0.94585
M1,2,M4,27,0.95228
M1,2,M4,28,0.96027
M1,2,M4,29,0.95493
M1,2,M4,30,0.94091
M1,3,M1,1,0.961
M1,3,M1,2,0.98903
M1,3,M1,3,1
M1,3,M1,4,0.99413
M1,3,M1,5,0.98892
M1,3,M2,6,0.9895
M1,3,M2,7,0.98794
M1,3,M2,8,0.98202
M1,3,M2,9,0.9704
M1,3,M2,10,0.97422
M1,3,M2,11,0.97159
M1,3,M3,12,0.95773
M1,3,M3,13,0.9439
M1,3,M3,14,0.94324
M1,3,M3,15,0.93204
M1,3,M4,16,0.88796
M1,3,M4,17,0.84515
M1,3,M4,18,0.84437
M1,3,M4,19,0.77076
M1,3,M4,20,0.73403
M1,3,M4,21,0.71655
M1,3,M4,22,0.79334
M1,3,M4,23,0.83953
M1,3,M4,24,0.89654
M1,3,M4,25,0.92172
M1,3,M4,26,0.95241
M1,3,M4,27,0.96009
M1,3,M4,28,0.96823
M1,3,M4,29,0.96464
M1,3,M4,30,0.94389
M1,4,M1,1,0.95495
M1,4,M1,2,0.98303
M1,4,M1,3,0.99413
M1,4,M1,4,1
M1,4,M1,5,0.99329
M1,4,M2,6,0.98668
M1,4,M2,7,0.99031
M1,4,M2,8,0.98878
M1,4,M2,9,0.97758
M1,4,M2,10,0.98115
M1,4,M2,11,0.98042
M1,4,M3,12,0.96877
M1,4,M3,13,0.95534
M1,4,M3,14,0.95546
M1,4,M3,15,0.94651
M1,4,M4,16,0.90653
M1,4,M4,17,0.86694
M1,4,M4,18,0.8655
M1,4,M4,19,0.79593
M1,4,M4,20,0.75875
M1,4,M4,21,0.74233
M1,4,M4,22,0.81732
M1,4,M4,23,0.85983
M1,4,M4,24,0.91437
M1,4,M4,25,0.93693
M1,4,M4,26,0.96472
M1,4,M4,27,0.97103
M1,4,M4,28,0.97578
M1,4,M4,29,0.97189
M1,4,M4,30,0.95132
M1,5,M1,1,0.9525
M1,5,M1,2,0.98538
M1,5,M1,3,0.98892
M1,5,M1,4,0.99329
M1,5,M1,5,1
M1,5,M2,6,0.9935
M1,5,M2,7,0.98689
M1,5,M2,8,0.98966
M1,5,M2,9,0.98515
M1,5,M2,10,0.98223
M1,5,M2,11,0.97775
M1,5,M3,12,0.97485
M1,5,M3,13,0.96356
M1,5,M3,14,0.95521
M1,5,M3,15,0.94754
M1,5,M4,16,0.90973
M1,5,M4,17,0.87846
M1,5,M4,18,0.88207
M1,5,M4,19,0.81775
M1,5,M4,20,0.78753
M1,5,M4,21,0.77318
M1,5,M4,22,0.84131
M1,5,M4,23,0.8833
M1,5,M4,24,0.92981
M1,5,M4,25,0.9501
M1,5,M4,26,0.9716
M1,5,M4,27,0.97375
M1,5,M4,28,0.97814
M1,5,M4,29,0.96984
M1,5,M4,30,0.95995
M2,6,M1,1,0.94745
M2,6,M1,2,0.97958
M2,6,M1,3,0.9895
M2,6,M1,4,0.98668
M2,6,M1,5,0.9935
M2,6,M2,6,1
M2,6,M2,7,0.99306
M2,6,M2,8,0.99169
M2,6,M2,9,0.98767
M2,6,M2,10,0.9865
M2,6,M2,11,0.9804
M2,6,M3,12,0.97537
M2,6,M3,13,0.96499
M2,6,M3,14,0.9568
M2,6,M3,15,0.9467
M2,6,M4,16,0.90541
M2,6,M4,17,0.8711
M2,6,M4,18,0.87525
M2,6,M4,19,0.80727
M2,6,M4,20,0.77667
M2,6,M4,21,0.76068
M2,6,M4,22,0.83033
M2,6,M4,23,0.87392
M2,6,M4,24,0.92271
M2,6,M4,25,0.9437
M2,6,M4,26,0.96695
M2,6,M4,27,0.96902
M2,6,M4,28,0.97511
M2,6,M4,29,0.96654
M2,6,M4,30,0.95583
M2,7,M1,1,0.9439
M2,7,M1,2,0.96968
M2,7,M1,3,0.98794
M2,7,M1,4,0.99031
M2,7,M1,5,0.98689
M2,7,M2,6,0.99306
M2,7,M2,7,1
M2,7,M2,8,0.99596
M2,7,M2,9,0.98631
M2,7,M2,10,0.99185
M2,7,M2,11,0.99026
M2,7,M3,12,0.97789
M2,7,M3,13,0.96633
M2,7,M3,14,0.96697
M2,7,M3,15,0.95647
M2,7,M4,16,0.91496
M2,7,M4,17,0.87383
M2,7,M4,18,0.87323
M2,7,M4,19,0.80191
M2,7,M4,20,0.76401
M2,7,M4,21,0.74644
M2,7,M4,22,0.82167
M2,7,M4,23,0.86321
M2,7,M4,24,0.9184
M2,7,M4,25,0.93946
M2,7,M4,26,0.96688
M2,7,M4,27,0.97145
M2,7,M4,28,0.97573
M2,7,M4,29,0.97072
M2,7,M4,30,0.94998
M2,8,M1,1,0.93963
M2,8,M1,2,0.96762
M2,8,M1,3,0.98202
M2,8,M1,4,0.98878
M2,8,M1,5,0.98966
M2,8,M2,6,0.99169
M2,8,M2,7,0.99596
M2,8,M2,8,1
M2,8,M2,9,0.99523
M2,8,M2,10,0.99574
M2,8,M2,11,0.99373
M2,8,M3,12,0.99001
M2,8,M3,13,0.97997
M2,8,M3,14,0.97528
M2,8,M3,15,0.96843
M2,8,M4,16,0.93284
M2,8,M4,17,0.90178
M2,8,M4,18,0.90388
M2,8,M4,19,0.841
M2,8,M4,20,0.80839
M2,8,M4,21,0.79371
M2,8,M4,22,0.86173
M2,8,M4,23,0.89918
M2,8,M4,24,0.94565
M2,8,M4,25,0.96259
M2,8,M4,26,0.98234
M2,8,M4,27,0.98276
M2,8,M4,28,0.98332
M2,8,M4,29,0.97506
M2,8,M4,30,0.96287
M2,9,M1,1,0.92747
M2,9,M1,2,0.95869
M2,9,M1,3,0.9704
M2,9,M1,4,0.97758
M2,9,M1,5,0.98515
M2,9,M2,6,0.98767
M2,9,M2,7,0.98631
M2,9,M2,8,0.99523
M2,9,M2,9,1
M2,9,M2,10,0.99509
M2,9,M2,11,0.98827
M2,9,M3,12,0.99414
M2,9,M3,13,0.98894
M2,9,M3,14,0.97556
M2,9,M3,15,0.96971
M2,9,M4,16,0.93824
M2,9,M4,17,0.91811
M2,9,M4,18,0.92493
M2,9,M4,19,0.86931
M2,9,M4,20,0.84365
M2,9,M4,21,0.83023
M2,9,M4,22,0.88902
M2,9,M4,23,0.92319
M2,9,M4,24,0.95974
M2,9,M4,25,0.97195
M2,9,M4,26,0.98335
M2,9,M4,27,0.97789
M2,9,M4,28,0.97676
M2,9,M4,29,0.96309
M2,9,M4,30,0.96077
M2,10,M1,1,0.93275
M2,10,M1,2,0.95757
M2,10,M1,3,0.97422
M2,10,M1,4,0.98115
M2,10,M1,5,0.98223
M2,10,M2,6,0.9865
M2,10,M2,7,0.99185
M2,10,M2,8,0.99574
M2,10,M2,9,0.99509
M2,10,M2,10,1
M2,10,M2,11,0.99688
M2,10,M3,12,0.99342
M2,10,M3,13,0.98857
M2,10,M3,14,0.98596
M2,10,M3,15,0.97828
M2,10,M4,16,0.94678
M2,10,M4,17,0.91647
M2,10,M4,18,0.91665
M2,10,M4,19,0.85547
M2,10,M4,20,0.82011
M2,10,M4,21,0.80339
M2,10,M4,22,0.8691
M2,10,M4,23,0.90119
M2,10,M4,24,0.94588
M2,10,M4,25,0.95783
M2,10,M4,26,0.97557
M2,10,M4,27,0.9725
M2,10,M4,28,0.9704
M2,10,M4,29,0.9598
M2,10,M4,30,0.94594
M2,11,M1,1,0.93267
M2,11,M1,2,0.95369
M2,11,M1,3,0.97159
M2,11,M1,4,0.98042
M2,11,M1,5,0.97775
M2,11,M2,6,0.9804
M2,11,M2,7,0.99026
M2,11,M2,8,0.99373
M2,11,M2,9,0.98827
M2,11,M2,10,0.99688
M2,11,M2,11,1
M2,11,M3,12,0.99232
M2,11,M3,13,0.98524
M2,11,M3,14,0.99025
M2,11,M3,15,0.98449
M2,11,M4,16,0.95538
M2,11,M4,17,0.92026
M2,11,M4,18,0.9161
M2,11,M4,19,0.85421
M2,11,M4,20,0.81338
M2,11,M4,21,0.79707
M2,11,M4,22,0.86638
M2,11,M4,23,0.89584
M2,11,M4,24,0.944
M2,11,M4,25,0.95543
M2,11,M4,26,0.97567
M2,11,M4,27,0.97457
M2,11,M4,28,0.96988
M2,11,M4,29,0.96203
M2,11,M4,30,0.94264
M3,12,M1,1,0.91837
M3,12,M1,2,0.94539
M3,12,M1,3,0.95773
M3,12,M1,4,0.96877
M3,12,M1,5,0.97485
M3,12,M2,6,0.97537
M3,12,M2,7,0.97789
M3,12,M2,8,0.99001
M3,12,M2,9,0.99414
M3,12,M2,10,0.99342
M3,12,M2,11,0.99232
M3,12,M3,12,1
M3,12,M3,13,0.99641
M3,12,M3,14,0.98901
M3,12,M3,15,0.98706
M3,12,M4,16,0.96429
M3,12,M4,17,0.94535
M3,12,M4,18,0.94785
M3,12,M4,19,0.8978
M3,12,M4,20,0.86789
M3,12,M4,21,0.8554
M3,12,M4,22,0.91214
M3,12,M4,23,0.93765
M3,12,M4,24,0.97157
M3,12,M4,25,0.97767
M3,12,M4,26,0.98592
M3,12,M4,27,0.97795
M3,12,M4,28,0.97018
M3,12,M4,29,0.95611
M3,12,M4,30,0.95205
M3,13,M1,1,0.90537
M3,13,M1,2,0.93139
M3,13,M1,3,0.9439
M3,13,M1,4,0.95534
M3,13,M1,5,0.96356
M3,13,M2,6,0.96499
M3,13,M2,7,0.96633
M3,13,M2,8,0.97997
M3,13,M2,9,0.98894
M3,13,M2,10,0.98857
M3,13,M2,11,0.98524
M3,13,M3,12,0.99641
M3,13,M3,13,1
M3,13,M3,14,0.99048
M3,13,M3,15,0.98738
M3,13,M4,16,0.96857
M3,13,M4,17,0.95385
M3,13,M4,18,0.95585
M3,13,M4,19,0.90949
M3,13,M4,20,0.88043
M3,13,M4,21,0.86682
M3,13,M4,22,0.91879
M3,13,M4,23,0.94
M3,13,M4,24,0.96954
M3,13,M4,25,0.97128
M3,13,M4,26,0.97571
M3,13,M4,27,0.9638
M3,13,M4,28,0.95421
M3,13,M4,29,0.93712
M3,13,M4,30,0.93551
M3,14,M1,1,0.90913
M3,14,M1,2,0.9261
M3,14,M1,3,0.94324
M3,14,M1,4,0.95546
M3,14,M1,5,0.95521
M3,14,M2,6,0.9568
M3,14,M2,7,0.96697
M3,14,M2,8,0.97528
M3,14,M2,9,0.97556
M3,14,M2,10,0.98596
M3,14,M2,11,0.99025
M3,14,M3,12,0.98901
M3,14,M3,13,0.99048
M3,14,M3,14,1
M3,14,M3,15,0.9956
M3,14,M4,16,0.97773
M3,14,M4,17,0.94934
M3,14,M4,18,0.94178
M3,14,M4,19,0.88907
M3,14,M4,20,0.8468
M3,14,M4,21,0.83041
M3,14,M4,22,0.89185
M3,14,M4,23,0.90976
M3,14,M4,24,0.94992
M3,14,M4,25,0.95151
M3,14,M4,26,0.96424
M3,14,M4,27,0.95644
M3,14,M4,28,0.94461
M3,14,M4,29,0.93261
M3,14,M4,30,0.91578
M3,15,M1,1,0.8998
M3,15,M1,2,0.9172
M3,15,M1,3,0.93204
M3,15,M1,4,0.94651
M3,15,M1,5,0.94754
M3,15,M2,6,0.9467
M3,15,M2,7,0.95647
M3,15,M2,8,0.96843
M3,15,M2,9,0.96971
M3,15,M2,10,0.97828
M3,15,M2,11,0.98449
M3,15,M3,12,0.98706
M3,15,M3,13,0.98738
M3,15,M3,14,0.9956
M3,15,M3,15,1
M3,15,M4,16,0.98866
M3,15,M4,17,0.96347
M3,15,M4,18,0.9556
M3,15,M4,19,0.90871
M3,15,M4,20,0.86702
M3,15,M4,21,0.85323
M3,15,M4,22,0.91121
M3,15,M4,23,0.92495
M3,15,M4,24,0.96045
M3,15,M4,25,0.95922
M3,15,M4,26,0.96765
M3,15,M4,27,0.95831
M3,15,M4,28,0.94274
M3,15,M4,29,0.93018
M3,15,M4,30,0.91711
M4,16,M1,1,0.86228
M4,16,M1,2,0.87634
M4,16,M1,3,0.88796
M4,16,M1,4,0.90653
M4,16,M1,5,0.90973
M4,16,M2,6,0.90541
M4,16,M2,7,0.91496
M4,16,M2,8,0.93284
M4,16,M2,9,0.93824
M4,16,M2,10,0.94678
M4,16,M2,11,0.95538
M4,16,M3,12,0.96429
M4,16,M3,13,0.96857
M4,16,M3,14,0.97773
M4,16,M3,15,0.98866
M4,16,M4,16,1
M4,16,M4,17,0.98408
M4,16,M4,18,0.96932
M4,16,M4,19,0.93492
M4,16,M4,20,0.8919
M4,16,M4,21,0.87955
M4,16,M4,22,0.92844
M4,16,M4,23,0.92968
M4,16,M4,24,0.95523
M4,16,M4,25,0.94458
M4,16,M4,26,0.94434
M4,16,M4,27,0.92923
M4,16,M4,28,0.90579
M4,16,M4,29,0.89019
M4,16,M4,30,0.88223
M4,17,M1,1,0.82022
M4,17,M1,2,0.83872
M4,17,M1,3,0.84515
M4,17,M1,4,0.86694
M4,17,M1,5,0.87846
M4,17,M2,6,0.8711
M4,17,M2,7,0.87383
M4,17,M2,8,0.90178
M4,17,M2,9,0.91811
M4,17,M2,10,0.91647
M4,17,M2,11,0.92026
M4,17,M3,12,0.94535
M4,17,M3,13,0.95385
M4,17,M3,14,0.94934
M4,17,M3,15,0.96347
M4,17,M4,16,0.98408
M4,17,M4,17,1
M4,17,M4,18,0.99011
M4,17,M4,19,0.9725
M4,17,M4,20,0.94278
M4,17,M4,21,0.9338
M4,17,M4,22,0.96488
M4,17,M4,23,0.95881
M4,17,M4,24,0.96509
M4,17,M4,25,0.94652
M4,17,M4,26,0.93044
M4,17,M4,27,0.90666
M4,17,M4,28,0.87884
M4,17,M4,29,0.85584
M4,17,M4,30,0.86649
M4,18,M1,1,0.81726
M4,18,M1,2,0.84047
M4,18,M1,3,0.84437
M4,18,M1,4,0.8655
M4,18,M1,5,0.88207
M4,18,M2,6,0.87525
M4,18,M2,7,0.87323
M4,18,M2,8,0.90388
M4,18,M2,9,0.92493
M4,18,M2,10,0.91665
M4,18,M2,11,0.9161
M4,18,M3,12,0.94785
M4,18,M3,13,0.95585
M4,18,M3,14,0.94178
M4,18,M3,15,0.9556
M4,18,M4,16,0.96932
M4,18,M4,17,0.99011
M4,18,M4,18,1
M4,18,M4,19,0.98495
M4,18,M4,20,0.96178
M4,18,M4,21,0.95605
M4,18,M4,22,0.98137
M4,18,M4,23,0.9775
M4,18,M4,24,0.9773
M4,18,M4,25,0.95858
M4,18,M4,26,0.93733
M4,18,M4,27,0.91134
M4,18,M4,28,0.88493
M4,18,M4,29,0.85915
M4,18,M4,30,0.8772
M4,19,M1,1,0.74939
M4,19,M1,2,0.77153
M4,19,M1,3,0.77076
M4,19,M1,4,0.79593
M4,19,M1,5,0.81775
M4,19,M2,6,0.80727
M4,19,M2,7,0.80191
M4,19,M2,8,0.841
M4,19,M2,9,0.86931
M4,19,M2,10,0.85547
M4,19,M2,11,0.85421
M4,19,M3,12,0.8978
M4,19,M3,13,0.90949
M4,19,M3,14,0.88907
M4,19,M3,15,0.90871
M4,19,M4,16,0.93492
M4,19,M4,17,0.9725
M4,19,M4,18,0.98495
M4,19,M4,19,1
M4,19,M4,20,0.98667
M4,19,M4,21,0.98027
M4,19,M4,22,0.98592
M4,19,M4,23,0.96974
M4,19,M4,24,0.95275
M4,19,M4,25,0.925
M4,19,M4,26,0.89054
M4,19,M4,27,0.85738
M4,19,M4,28,0.82441
M4,19,M4,29,0.79389
M4,19,M4,30,0.82522
M4,20,M1,1,0.70877
M4,20,M1,2,0.7397
M4,20,M1,3,0.73403
M4,20,M1,4,0.75875
M4,20,M1,5,0.78753
M4,20,M2,6,0.77667
M4,20,M2,7,0.76401
M4,20,M2,8,0.80839
M4,20,M2,9,0.84365
M4,20,M2,10,0.82011
M4,20,M2,11,0.81338
M4,20,M3,12,0.86789
M4,20,M3,13,0.88043
M4,20,M3,14,0.8468
M4,20,M3,15,0.86702
M4,20,M4,16,0.8919
M4,20,M4,17,0.94278
M4,20,M4,18,0.96178
M4,20,M4,19,0.98667
M4,20,M4,20,1
M4,20,M4,21,0.99181
M4,20,M4,22,0.98307
M4,20,M4,23,0.96908
M4,20,M4,24,0.94001
M4,20,M4,25,0.91142
M4,20,M4,26,0.86788
M4,20,M4,27,0.83072
M4,20,M4,28,0.79916
M4,20,M4,29,0.76409
M4,20,M4,30,0.81011
M4,21,M1,1,0.69285
M4,21,M1,2,0.7247
M4,21,M1,3,0.71655
M4,21,M1,4,0.74233
M4,21,M1,5,0.77318
M4,21,M2,6,0.76068
M4,21,M2,7,0.74644
M4,21,M2,8,0.79371
M4,21,M2,9,0.83023
M4,21,M2,10,0.80339
M4,21,M2,11,0.79707
M4,21,M3,12,0.8554
M4,21,M3,13,0.86682
M4,21,M3,14,0.83041
M4,21,M3,15,0.85323
M4,21,M4,16,0.87955
M4,21,M4,17,0.9338
M4,21,M4,18,0.95605
M4,21,M4,19,0.98027
M4,21,M4,20,0.99181
M4,21,M4,21,1
M4,21,M4,22,0.98879
M4,21,M4,23,0.97357
M4,21,M4,24,0.93962
M4,21,M4,25,0.91034
M4,21,M4,26,0.86294
M4,21,M4,27,0.8256
M4,21,M4,28,0.79203
M4,21,M4,29,0.75696
M4,21,M4,30,0.80857
M4,22,M1,1,0.76588
M4,22,M1,2,0.79714
M4,22,M1,3,0.79334
M4,22,M1,4,0.81732
M4,22,M1,5,0.84131
M4,22,M2,6,0.83033
M4,22,M2,7,0.82167
M4,22,M2,8,0.86173
M4,22,M2,9,0.88902
M4,22,M2,10,0.8691
M4,22,M2,11,0.86638
M4,22,M3,12,0.91214
M4,22,M3,13,0.91879
M4,22,M3,14,0.89185
M4,22,M3,15,0.91121
M4,22,M4,16,0.92844
M4,22,M4,17,0.96488
M4,22,M4,18,0.98137
M4,22,M4,19,0.98592
M4,22,M4,20,0.98307
M4,22,M4,21,0.98879
M4,22,M4,22,1
M4,22,M4,23,0.99289
M4,22,M4,24,0.9754
M4,22,M4,25,0.95364
M4,22,M4,26,0.91924
M4,22,M4,27,0.88961
M4,22,M4,28,0.85966
M4,22,M4,29,0.83075
M4,22,M4,30,0.86816
M4,23,M1,1,0.80563
M4,23,M1,2,0.84296
M4,23,M1,3,0.83953
M4,23,M1,4,0.85983
M4,23,M1,5,0.8833
M4,23,M2,6,0.87392
M4,23,M2,7,0.86321
M4,23,M2,8,0.89918
M4,23,M2,9,0.92319
M4,23,M2,10,0.90119
M4,23,M2,11,0.89584
M4,23,M3,12,0.93765
M4,23,M3,13,0.94
M4,23,M3,14,0.90976
M4,23,M3,15,0.92495
M4,23,M4,16,0.92968
M4,23,M4,17,0.95881
M4,23,M4,18,0.9775
M4,23,M4,19,0.96974
M4,23,M4,20,0.96908
M4,23,M4,21,0.97357
M4,23,M4,22,0.99289
M4,23,M4,23,1
M4,23,M4,24,0.99022
M4,23,M4,25,0.97749
M4,23,M4,26,0.94989
M4,23,M4,27,0.92555
M4,23,M4,28,0.90302
M4,23,M4,29,0.87667
M4,23,M4,30,0.91216
M4,24,M1,1,0.86017
M4,24,M1,2,0.89441
M4,24,M1,3,0.89654
M4,24,M1,4,0.91437
M4,24,M1,5,0.92981
M4,24,M2,6,0.92271
M4,24,M2,7,0.9184
M4,24,M2,8,0.94565
M4,24,M2,9,0.95974
M4,24,M2,10,0.94588
M4,24,M2,11,0.944
M4,24,M3,12,0.97157
M4,24,M3,13,0.96954
M4,24,M3,14,0.94992
M4,24,M3,15,0.96045
M4,24,M4,16,0.95523
M4,24,M4,17,0.96509
M4,24,M4,18,0.9773
M4,24,M4,19,0.95275
M4,24,M4,20,0.94001
M4,24,M4,21,0.93962
M4,24,M4,22,0.9754
M4,24,M4,23,0.99022
M4,24,M4,24,1
M4,24,M4,25,0.99504
M4,24,M4,26,0.98122
M4,24,M4,27,0.96475
M4,24,M4,28,0.94675
M4,24,M4,29,0.92681
M4,24,M4,30,0.94628
M4,25,M1,1,0.88171
M4,25,M1,2,0.91888
M4,25,M1,3,0.92172
M4,25,M1,4,0.93693
M4,25,M1,5,0.9501
M4,25,M2,6,0.9437
M4,25,M2,7,0.93946
M4,25,M2,8,0.96259
M4,25,M2,9,0.97195
M4,25,M2,10,0.95783
M4,25,M2,11,0.95543
M4,25,M3,12,0.97767
M4,25,M3,13,0.97128
M4,25,M3,14,0.95151
M4,25,M3,15,0.95922
M4,25,M4,16,0.94458
M4,25,M4,17,0.94652
M4,25,M4,18,0.95858
M4,25,M4,19,0.925
M4,25,M4,20,0.91142
M4,25,M4,21,0.91034
M4,25,M4,22,0.95364
M4,25,M4,23,0.97749
M4,25,M4,24,0.99504
M4,25,M4,25,1
M4,25,M4,26,0.993
M4,25,M4,27,0.98199
M4,25,M4,28,0.96948
M4,25,M4,29,0.95317
M4,25,M4,30,0.9689
M4,26,M1,1,0.91169
M4,26,M1,2,0.94585
M4,26,M1,3,0.95241
M4,26,M1,4,0.96472
M4,26,M1,5,0.9716
M4,26,M2,6,0.96695
M4,26,M2,7,0.96688
M4,26,M2,8,0.98234
M4,26,M2,9,0.98335
M4,26,M2,10,0.97557
M4,26,M2,11,0.97567
M4,26,M3,12,0.98592
M4,26,M3,13,0.97571
M4,26,M3,14,0.96424
M4,26,M3,15,0.96765
M4,26,M4,16,0.94434
M4,26,M4,17,0.93044
M4,26,M4,18,0.93733
M4,26,M4,19,0.89054
M4,26,M4,20,0.86788
M4,26,M4,21,0.86294
M4,26,M4,22,0.91924
M4,26,M4,23,0.94989
M4,26,M4,24,0.98122
M4,26,M4,25,0.993
M4,26,M4,26,1
M4,26,M4,27,0.99621
M4,26,M4,28,0.98854
M4,26,M4,29,0.97795
M4,26,M4,30,0.98088
M4,27,M1,1,0.91854
M4,27,M1,2,0.95228
M4,27,M1,3,0.96009
M4,27,M1,4,0.97103
M4,27,M1,5,0.97375
M4,27,M2,6,0.96902
M4,27,M2,7,0.97145
M4,27,M2,8,0.98276
M4,27,M2,9,0.97789
M4,27,M2,10,0.9725
M4,27,M2,11,0.97457
M4,27,M3,12,0.97795
M4,27,M3,13,0.9638
M4,27,M3,14,0.95644
M4,27,M3,15,0.95831
M4,27,M4,16,0.92923
M4,27,M4,17,0.90666
M4,27,M4,18,0.91134
M4,27,M4,19,0.85738
M4,27,M4,20,0.83072
M4,27,M4,21,0.8256
M4,27,M4,22,0.88961
M4,27,M4,23,0.92555
M4,27,M4,24,0.96475
M4,27,M4,25,0.98199
M4,27,M4,26,0.99621
M4,27,M4,27,1
M4,27,M4,28,0.99535
M4,27,M4,29,0.99029
M4,27,M4,30,0.98643
M4,28,M1,1,0.92305
M4,28,M1,2,0.96027
M4,28,M1,3,0.96823
M4,28,M1,4,0.97578
M4,28,M1,5,0.97814
M4,28,M2,6,0.97511
M4,28,M2,7,0.97573
M4,28,M2,8,0.98332
M4,28,M2,9,0.97676
M4,28,M2,10,0.9704
M4,28,M2,11,0.96988
M4,28,M3,12,0.97018
M4,28,M3,13,0.95421
M4,28,M3,14,0.94461
M4,28,M3,15,0.94274
M4,28,M4,16,0.90579
M4,28,M4,17,0.87884
M4,28,M4,18,0.88493
M4,28,M4,19,0.82441
M4,28,M4,20,0.79916
M4,28,M4,21,0.79203
M4,28,M4,22,0.85966
M4,28,M4,23,0.90302
M4,28,M4,24,0.94675
M4,28,M4,25,0.96948
M4,28,M4,26,0.98854
M4,28,M4,27,0.99535
M4,28,M4,28,1
M4,28,M4,29,0.99585
M4,28,M4,30,0.98979
M4,29,M1,1,0.91976
M4,29,M1,2,0.95493
M4,29,M1,3,0.96464
M4,29,M1,4,0.97189
M4,29,M1,5,0.96984
M4,29,M2,6,0.96654
M4,29,M2,7,0.97072
M4,29,M2,8,0.97506
M4,29,M2,9,0.96309
M4,29,M2,10,0.9598
M4,29,M2,11,0.96203
M4,29,M3,12,0.95611
M4,29,M3,13,0.93712
M4,29,M3,14,0.93261
M4,29,M3,15,0.93018
M4,29,M4,16,0.89019
M4,29,M4,17,0.85584
M4,29,M4,18,0.85915
M4,29,M4,19,0.79389
M4,29,M4,20,0.76409
M4,29,M4,21,0.75696
M4,29,M4,22,0.83075
M4,29,M4,23,0.87667
M4,29,M4,24,0.92681
M4,29,M4,25,0.95317
M4,29,M4,26,0.97795
M4,29,M4,27,0.99029
M4,29,M4,28,0.99585
M4,29,M4,29,1
M4,29,M4,30,0.98616
M4,30,M1,1,0.89547
M4,30,M1,2,0.94091
M4,30,M1,3,0.94389
M4,30,M1,4,0.95132
M4,30,M1,5,0.95995
M4,30,M2,6,0.95583
M4,30,M2,7,0.94998
M4,30,M2,8,0.96287
M4,30,M2,9,0.96077
M4,30,M2,10,0.94594
M4,30,M2,11,0.94264
M4,30,M3,12,0.95205
M4,30,M3,13,0.93551
M4,30,M3,14,0.91578
M4,30,M3,15,0.91711
M4,30,M4,16,0.88223
M4,30,M4,17,0.86649
M4,30,M4,18,0.8772
M4,30,M4,19,0.82522
M4,30,M4,20,0.81011
M4,30,M4,21,0.80857
M4,30,M4,22,0.86816
M4,30,M4,23,0.91216
M4,30,M4,24,0.94628
M4,30,M4,25,0.9689
M4,30,M4,26,0.98088
M4,30,M4,27,0.98643
M4,30,M4,28,0.98979
M4,30,M4,29,0.98616
M4,30,M4,30,1")

有了这个,我得到了你展示的同样的情节。

您可以像第一次尝试一样添加注释栏

p + 
  annotate("rect", xmin=1, xmax=5, ymin=1, ymax=2, fill="red") +
  annotate("rect", xmin=6, xmax=11, ymin=1, ymax=2, fill="blue") +
  annotate("rect", xmin=12, xmax=15, ymin=1, ymax=2, fill="green") +
  annotate("rect", xmin=16, xmax=30, ymin=1, ymax=2, fill="black")

我使用了您的xmin/xmaxDf

在此处输入图像描述

对于您的第二种方法,我不知道是什么Dom1Dom2但我猜

p +
  geom_vline(aes(xintercept=c(5.5, 11.5, 15.5)), 
             linetype="solid", colour="black", size=0.7)

在此处输入图像描述

您在评论中展示的第三种方法可以改编为

df = c(5,13,16,20) 
dfx <- data.frame(df) 
ggplot(data, aes(Res1,Res2,fill=Val)) + 
  geom_tile() + 
  scale_fill_gradient(low="white", high="blue") + 
  theme_bw() + 
  geom_hline(data=dfx, aes(yintercept=df), linetype="solid", 
             colour="black", size=2) + 
  geom_vline(data=dfx, aes(xintercept=df), linetype="solid", 
             colour="black", size=2) + 
  scale_x_continuous(breaks=c(5,13,16,20), expand=c(0,0)) + 
  scale_y_continuous(breaks=c(5,13,16,20), expand=c(0,0))

屈服 在此处输入图像描述

于 2013-04-19T16:55:24.680 回答