看板Programming
标 题? MatLab contourf and colorbar
发信站KKCITY (Thu Jan 3 00:25:21 2008)
转信站ptt!ctu-reader!ctu-gate!news.nctu!news.ntu!news.au!zoonews.ee.ntu!news
我试着透过下列程式片段去了解 MatLab 的两个命令 contourf() and colorbar
contourf() 画的是 >= 的 contour 而且会把 >= 的部分填满颜色
colorbar 则是在图的旁边把等位线的值跟对应的颜色标出来 可是照我下面的
程式显示的结果不太对劲
对照图一的等位线群跟图二的填满的等位线群 红色区域应该是 >= 1
棕色区域则是 >= 0 蓝色区域则是 >= -1 而空白区域则是 < -1
可是这样跟旁边的色表 (colorbar) 根本对不起来 根据色表
蓝色 >= -1.0 and < -0.5
绿色 >= -0.5 and < 0.0
棕色 >= 0.0 and < 0.5
红色 >= 0.5 and < 1.0
而且这一来 >=1 的部分怎麽表示?
by Cheng Cosine
Jan/02/2k8 NC
clear all; clc;
% generate field to plot
P = peaks;
Pmin = min(P(:)); Pmax = max(P(:));
% rescale to desired range of field values
Psmin = -2.0E0; Psmax = 2.0E0;
Pscaled = Psmin+( Psmax-Psmin )*( P-Pmin )/( Pmax-Pmin );
v = [-1, 0, 1];
% ---------------------------------------------------------
% Case-000 MatLab default
figure
[cs, h] = contour(Pscaled);
colorbar
clabel(cs)
% ---------------------------------------------------------
% Case-01
cmap1 = [0.0 0.0 1.0; ...
0.0 1.0 0.0; ...
0.5 0.5 0.0; ...
1.0 0.0 0.0];
figure
colormap(cmap1)
[cs1, h1] = contourf(Pscaled, v);
colorbar
clabel(cs1, v)
--
┌─────◆KKCITY◆─────┐ KK免/费/拨/接 ◤
│ bbs.kkcity.com.tw │▏电话(1):449◤1999 电话(2):4058-6000
└──《From:152.16.233.74
》──┘▏帐号:kkcity 密码:kkcity
--