简体   繁体   English

使用R创建热图以绘制正值和负值

[英]Using R to create a heat map to plot positive and negative values

I'm pretty new to R and I'm trying to create an heat map. 我是R的新手,正在尝试创建热图。 This is an example of the data I created 这是我创建的数据的一个示例

Point         Distance
9273206       11
9273206       21
9273206       -25
9279872       -9
9279872       10
9770644        9
10315636       25
13144752        5
13257732       -3

A value in the Point column can occur multiple times. 点列中的值可以出现多次。 I'm trying to create a heat map which represents the unique value from the Point column (on a horizontal line), the value from the Distance column are plotted around it. 我正在尝试创建一个热图,该热图表示“点”列中的唯一值(在水平线上),“距离”列中的值围绕它绘制。 The negative value on the left en the positive on the right. 左边的负值和右边的正值。 This is an example of what I'm trying to create: 这是我要创建的示例:

http://i.imgur.com/AhVAxOQ.png http://i.imgur.com/AhVAxOQ.png

The black line in the middle represents the unique values from the Point column and the red lines the data points from the Distance column. 中间的黑线表示“点”列中的唯一值,红线表示“距离”列中的数据点。

I have look around to find ways to plot this, but could not find anything. 我环顾四周,以寻找方法对此进行绘图,但找不到任何东西。 Could someone explain how to do this or give me a few tips. 有人可以解释如何执行此操作或给我一些提示。 Or should I use something totally different? 还是我应该使用完全不同的东西?

thanks in advance for your help 在此先感谢您的帮助

If someone can help me out with the text issue, I came up with this. 如果有人可以帮助我解决text问题,我想到了这个。

plot(Point ~ Distance, data = yourData, pch = '.', cex = 10, 
     col = 'red', ylab = "", yaxt = "n", las = 1)
abline(v = 0)

Which produces the following plot. 产生以下图。

在此处输入图片说明

The unique axis values were a bit more challenging. 唯一的轴值更具挑战性。 I thought text might be the right way to get there, but my result is a bit hard to read. 我认为text可能是到达那里的正确方法,但我的结果有点难以阅读。 Hopefully someone knows how to fix it. 希望有人知道如何解决它。

 text(unique(dat$Point), labels = unique(dat$Point), 
      adj = c(1,2), pos = 2, offset = 0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM