R中存在哪些可视化“距离矩阵"的技术? [英] What techniques exists in R to visualize a "distance matrix"?

查看:79
本文介绍了R中存在哪些可视化“距离矩阵"的技术?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我正在写的文章中提出一个距离矩阵以获得良好的可视化效果.

I wish to present a distance matrix in an article I am writing, and I am looking for good visualization for it.

到目前为止,我遇到了气球图(我使用了一些代码和示例-使用形状很酷,但是我不确定在这里如何使用它.)

So far I came across balloon plots (I used it here, but I don't think it will work in this case), heatmaps (here is a nice example, but they don't allow to present the numbers in the table, correct me if I am wrong. Maybe half the table in colors and half with numbers would be cool) and lastly correlation ellipse plots (here is some code and example - which is cool to use a shape, but I am not sure how to use it here).

还有多种聚类方法,但是它们将聚合数据(这不是我想要的),而我想要的是呈现所有数据.

There are also various clustering methods but they will aggregate the data (which is not what I want) while what I want is to present all of the data.

示例数据:

nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv")
dist(nba[1:20, -1], )

我愿意接受想法.

推荐答案

Tal,这是在热图上重叠文本的快速方法.请注意,这依赖于image而不是heatmap,因为后者会使图形偏移,从而使将文本放置在正确位置更加困难.

Tal, this is a quick way to overlap text over an heatmap. Note that this relies on image rather than heatmap as the latter offsets the plot, making it more difficult to put text in the correct position.

说实话,我认为这张图显示的信息太多,很难读取...您可能只想写特定的值.

To be honest, I think this graph shows too much information, making it a bit difficult to read... you may want to write only specific values.

另外,另一个更快的选择是将图形另存为pdf,将其导入Inkscape(或类似软件)中,并在需要的地方手动添加文本.

also, the other quicker option is to save your graph as pdf, import it in Inkscape (or similar software) and manually add the text where needed.

希望这会有所帮助

nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv")

dst <- dist(nba[1:20, -1],)
dst <- data.matrix(dst)

dim <- ncol(dst)

image(1:dim, 1:dim, dst, axes = FALSE, xlab="", ylab="")

axis(1, 1:dim, nba[1:20,1], cex.axis = 0.5, las=3)
axis(2, 1:dim, nba[1:20,1], cex.axis = 0.5, las=1)

text(expand.grid(1:dim, 1:dim), sprintf("%0.1f", dst), cex=0.6)

这篇关于R中存在哪些可视化“距离矩阵"的技术?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆