绘制在MATLAB颜色codded图 [英] plotting color codded graph in matlab

查看:208
本文介绍了绘制在MATLAB颜色codded图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用.dat文件绘制彩色codded 2D图形。在该文件中的数据被布置为

48.000000 0.000184 0.400000
48.500000 0.000185 0.400000
49.000000 0.000186 0.400000
49.500000 0.000187 0.400000
50.000000 0.000187 0.400000
50.500000 0.000186 0.400000
51.000000 0.000186 0.400000
51.500000 0.000186 0.400000
52.000000 0.000185 0.400000
52.500000 0.000184 0.400000
53.000000 0.000184 0.400000
53.500000 0.000182 0.400000
54.000000 0.000180 0.400000
54.500000 0.000179 0.400000
55.000000 0.000177 0.400000
55.500000 0.000174 0.400000
56.000000 0.000172 0.400000

下面3列也在发生变化。有近3000行。我需要绘制codded第一和第二变量之间的色彩2D图形已经把作为第三可变高度的颜色。 有人可以帮我吗?

解决方案

如果你希望你的数据的颜色由深到去根据第3列的值的光,那么你可能是最好关闭只是使用<一个HREF =htt​​p://www.mathworks.com/help/techdoc/ref/scatter.html相对=nofollow>分散功能。根据该文件

  

<强>散射(X,Y,S,C)显示在由矢量X和Y中指定的位置(它必须是相同的尺寸)的彩色圆圈

     

取值确定每个标记的区域......

     

C 确定每个标记的颜色。当C是一个矢量的长度相同的X和Y,C中的值线性映射到颜色在当前颜色表

这意味着,你可以明确地选择,你希望自己的数据使用的颜色表。假设的 COL1 COL2 COL3 的包含各数据的三列的值,以下code将以此为散射积与COL1和col2限定x和y位置(分别)和COL3限定每个点的颜色。

 散射(COL1,COL2,25,COL3,'。');
颜色表(灰色);
 

绘制分布图后,我明确设置颜色映射到的灰色的,以便在COL3用小值点,将是黑暗和那些有较大的值会发光。注意,在这个例子中,标记物面积是25和标记类型是一个点(。),所指定的第三和第五参数的分散的功能。

有,你可以再说的灰色的使用许多其他的颜色表。例如,的可能会更美观。该文档的颜色映射功能使您的其他选项的详细信息。

I need to plot a color codded 2d graph using a .dat file. data in the file is arranged as

48.000000 0.000184 0.400000 
48.500000 0.000185 0.400000 
49.000000 0.000186 0.400000 
49.500000 0.000187 0.400000 
50.000000 0.000187 0.400000 
50.500000 0.000186 0.400000 
51.000000 0.000186 0.400000 
51.500000 0.000186 0.400000 
52.000000 0.000185 0.400000 
52.500000 0.000184 0.400000 
53.000000 0.000184 0.400000 
53.500000 0.000182 0.400000 
54.000000 0.000180 0.400000 
54.500000 0.000179 0.400000 
55.000000 0.000177 0.400000 
55.500000 0.000174 0.400000 
56.000000 0.000172 0.400000 

here 3rd column is also changing. There are almost 3000 lines. I need to plot a color codded 2d graph between 1st and 2nd variable and color has to put as height of 3rd variable. Can someone help me ?

解决方案

If you want the colors of your data to go from dark to light based on the value in column 3, then you might be best off just using the scatter function. According to the documentation

scatter(X,Y,S,C) displays colored circles at the locations specified by the vectors X and Y (which must be the same size).

S determines the area of each marker ...

C determines the color of each marker. When C is a vector the same length as X and Y, the values in C are linearly mapped to the colors in the current colormap.

This means that you can explicitly chose the colormap that you want your data to use. Assuming col1, col2, col3 contain the values in each of the three columns of your data, the following code will draw a scatter plot with col1 and col2 defining the x and y positions (respectively) and col3 defining the color of each point.

scatter(col1, col2, 25, col3, '.');
colormap(gray);

After drawing the scatter plot, I explicitly set the colormap to gray so that points in col3 with a small value will be dark and those with a large value will be light. Note that in this example the marker area is 25 and the marker type is a dot ('.'), as specified by the 3rd and 5th parameters of the scatter function.

There are many other colormaps that you could use besides gray. For example, hot or copper might be more aesthetically pleasing. The doc for the colormap function gives more info on your other options.

这篇关于绘制在MATLAB颜色codded图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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