加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

如何修改color bar的范围

(2013-01-01 11:20:36)
标签:

杂谈

手动调节 : edit - colormap 然后选择数值即可


转自 http://www.mathworks.com/support/solutions/en/data/1-4SZI19/index.html?product=ML&solution=1-4SZI19

 

How can I have a standard colorbar for different plots in MATLAB 7.0.4 (R14SP2)?

Date Last Modified: Friday, June 26, 2009

Solution ID: 1-4SZI19
Product: MATLAB
Reported in Release: R14SP2
Platform: Linux
Operating System: Linux Any

Subject:

How can I have a standard colorbar for different plots in MATLAB 7.0.4 (R14SP2)?

Problem Description:

I am trying to compare different sets of data, with different sets of ranges using PCOLOR.

The COLORBAR function generates a different colorbar for each set of data. Thus, it becomes difficult for me to compare the different data sets, as the ranges and tick labes on the colorbars are different for each data set. So, how can I have a standard colorbar for different plots?

Solution:

In order to have a standard colorbar for plots generated using PCOLOR you first need to set the same ‘CLim’ property for the axes of each plot before you enable the colorbar for that plot (i.e. by executing the COLORBAR command).

Since the colorbar chooses limits and labels according to the ‘CLim’ property of the associated axes, it is important to create (or recreate) the colorbar after setting the ‘CLim’ property.

For example:
% Plot # 1
figure(1);
a = axes;
C = rand(5); % Random values between 0 and 1 for Plot#1
p = pcolor(C);
set(a, 'CLim', [0 1]); % CLim property is set for figure(1) before colobar
colorbar; % colorbar is set for figure(1)

% Clears the workspace
clear all;
clc;

% Plot # 2
figure(2);
a = axes;
C = .25*rand(5) + .5; % Create random values between .375 and .625 for Plot # 2
p = pcolor(C);
set(a, 'CLim', [0 1]); % CLim property is set for figure(2) before colobar
colorbar; % colorbar is set for figure(2)

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有