如何制作“颜色图"?在MATLAB中积?? [英] How can I make a "color map" plot in matlab?

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

问题描述

我有一些以matlab格式存储的数据(两个参数的函数),我想使用matlab进行绘制.读入数据后,使用mesh()进行绘图.我的mesh()图为我提供了该函数的颜色和表面高度值,如下所示:

I have some data (a function of two parameters) stored in a matlab format, and I'd like to use matlab to plot it. Once I read the data in, I use mesh() to make a plot. My mesh() plot gives me the the value of the function as a color and a surface height, like this:

我应该使用哪种matlab绘图功能来制作2D网格图,其中因变量仅表示为一种颜色?我正在gnuplot中寻找pm3d map之类的东西.

What matlab plotting function should I use to make a 2D mesh plot where the dependent variable is represented as only a color? I'm looking for something like pm3d map in gnuplot.

推荐答案

默认情况下,mesh将根据(默认)jet颜色图(即,热度更高)对表面值进行着色.您还可以将surf用于填充的表面补丁并将'EdgeColor'属性设置为'None'(因此补丁边缘不可见).

By default mesh will color surface values based on the (default) jet colormap (i.e. hot is higher). You can additionally use surf for filled surface patches and set the 'EdgeColor' property to 'None' (so the patch edges are non-visible).

[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;

% surface in 3D
figure;
surf(Z,'EdgeColor','None');

2D地图:您可以通过切换图形的view属性

2D map: You can get a 2D map by switching the view property of the figure

% 2D map using view
figure;
surf(Z,'EdgeColor','None');
view(2);    

...或将Z中的值视为矩阵,使用imagesc将其视为缩放图像,然后选择适当的

... or treating the values in Z as a matrix, viewing it as a scaled image using imagesc and selecting an appropriate colormap.

% using imagesc to view just Z
figure;
imagesc(Z); 
colormap jet; 

地图的颜色调色板由colormap(map)控制,其中map可以自定义,也可以由MATLAB提供的任何内置颜色图:

The color pallet of the map is controlled by colormap(map), where map can be custom or any of the built-in colormaps provided by MATLAB:

更新/定义地图:可以通过常规的MATLAB选项控制地图上的多个设计选项(分辨率,平滑度,轴等).正如@Floris所指出的,这是一个平滑的,等轴,无轴的标签图,适用于以下示例:

Update/Refining the map: Several design options on the map (resolution, smoothing, axis etc.) can be controlled by the regular MATLAB options. As @Floris points out, here is a smoothed, equal-axis, no-axis labels maps, adapted to this example:

figure;
surf(X, Y, Z,'EdgeColor', 'None', 'facecolor', 'interp');
view(2);
axis equal; 
axis off;

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

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