colorbar: cdata and colors

22 ビュー (過去 30 日間)
Maciej
Maciej 2012 年 5 月 28 日
Hi all,
I have a question related to colobar. I am using imagesc function to do some plots, the problem is the same value (cdata) are described by different colors in colorbar (for example in one plot 1.6 corresponds yellow, while in ohter plot yellow corresponds 1.3 ). So my question is how can I modify the colobar in that way in each plots the same values were described by the same color? Thanks in advance for help.
regards Maciek

採用された回答

Teja Muppirala
Teja Muppirala 2012 年 5 月 29 日
The CAXIS command can used to set the scaling limits on the color, in the same way that you set XLIM or YLIM. For example:
figure
imagesc([1 2 3 4 5 6 7 8 9 10])
colorbar
figure
imagesc(5:.5:10)
ax2 = gca;
caxis(ax2,[1 10])
colorbar

その他の回答 (4 件)

Stephen
Stephen 2012 年 5 月 29 日
imagesc automatically scales your image to 'fit' to the colorbar. It can be a huge pain sometimes. If you can get away with it, just plot the images in the same picture like,
a=image 1
b=image 2
imagesc([a b])
they'd have to be the same size though...
another thing you could do is reset the range in the colorbar so that it matches the first image.
create a colormap and crop off some stuff,
cm = jet(100);cm(end-39:end,:)=[];colormap(cm)
or, you could just use image() to plot the pics... if they're too dark, just multiply them by some value so they show up nicely. good luck

Eskapp
Eskapp 2012 年 5 月 29 日
Have a look to the function colormapeditor. There is a tutorial in Matlab documentation.
I think it is exactly what you need.

Maciej
Maciej 2012 年 5 月 30 日
Thanks Teja Muppirala,
Your answer turned out the simplest way to solove my problem, btw I tried before doing something with caxis function but I had to do someting wrong
Regards Maciek

Matlab2010
Matlab2010 2012 年 10 月 8 日
I have been trying to apply the answers given here to http://www.mathworks.com/matlabcentral/answers/50180-caxis-and-colorbar-scaling-issue but they do not seem to work.
Can anyone comment?

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by