Matlab二维密度图 [英] Matlab 2-D density plot

查看:851
本文介绍了Matlab二维密度图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对包含两个具有不同范围的列的数据进行密度图绘制. RMSD列为[0-2],角度为[0-200]范围.

I am trying to do a density plot for a data containing two columns with different ranges. The RMSD column is [0-2] and Angle is [0-200] ranges.

我在文件中的数据是这样的:

My data in the file is like this:

0.0225370 37.088  
0.1049553 35.309  
0.0710002 33.993  
0.0866880 34.708  
0.0912664 33.011  
0.0932054 33.191  
0.1083590 37.276  
0.1104145 34.882  
0.1027977 34.341  
0.0896688 35.991  
0.1047578 36.457  
0.1215936 38.914  
0.1105484 35.051  
0.0974138 35.533  
0.1390955 33.601  
0.1333878 32.133  
0.0933365 35.714  
0.1200465 33.038  
0.1155794 33.694  
0.1125247 34.522  
0.1181806 37.890  
0.1291700 38.871  

  1. 我希望x轴和y轴都被合并到范围的1/10处
  2. 要从同一轴开始的两个轴的0
  3. 像这样打印矩阵的每个网格中的元素数量,并根据这些元素数量绘制密度图

  1. I want both x and y axis to be binned 1/10th of the range
  2. The 0 of both the axis to be starting in the same
  3. Print the number of elements in each grid of the matrix like this and make a density plot based on these number of elements

   0 0.1 0.2 (RMSD)   
0  0 1 3
20 2 0 4
40 1 0 5
60 0 0 2
(Angle)

我可以找到进行一维装仓的方法,但后来我对如何从这些值制作密度图感到困惑,甚至还不敢尝试进行二维装箱+绘图.

I can find ways to do 1-D binning but then I am stumped about how to make a density plot from those values and havent even dared to attempt2-D binning + plotting.

感谢您的帮助

推荐答案

我认为您想要 hist3 .假设您要分配边(而不是边中心),请使用

I think you want hist3. Assuming you want to specifty bin edges (not bin centers), use

result = hist3(data, 'Edges', {[0 .1 .2], [0 20 40 60]}).';

其中data表示您的数据.

从链接的文档中:

hist3(X,'Edges',edges),其中edges是具有单调非递减值的数字矢量的两元素单元格数组,使用二维栅格网格,其一维边在edges{1}处且在在第二个.第(ij)个bin包含值X(k,:) if

hist3(X,'Edges',edges), where edges is a two-element cell array of numeric vectors with monotonically non-decreasing values, uses a 2-D grid of bins with edges at edges{1} in the first dimension and at edges{2} in the second. The (i,j)th bin includes the value X(k,:) if

edges{1}(i) <= X(k,1) < edges{1}(i+1)
edges{2}(j) <= X(k,2) < edges{2}(j+1)

给出您的示例数据

result =
     0     0     0
     8    14     0
     0     0     0
     0     0     0

这篇关于Matlab二维密度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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