specify and connect colorbar ranges
11 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I'm having troubles making several colorplots and 'connect' the color ranges between them. For example, the plotted values are between 0.1 and 0.25 for the first and 0.25 to 0.5 for the second. What I want is plot the first data set using colors that range from blue to green, and then the second with colors ranging from green to red. Or something like this but at least making sure that the max color of plot 1 is the min color of plot 2. As they are in different scripts, I need an easy way to manually 'set' the color ranges. I have been trying to get this to work with caxis/ clim, but these seem to only change the bar limits, rather than the actual colors... I can't get it to work.
Here is my code for the first graph:
for j = 1: length(stat)
file=char(stat(j,1)); %metric to be plotted
temp=eval(file); %get data
figure(j)
h=pcolor(X/10,Y/10,temp); hold on %start pseudoplot
set(h, 'edgecolor','none'); %get rid of edgelines
title(titles(j),'fontsize',11, 'fontweight', 'bold'); % add title
caxis([0.1 0.25]) % specify colorbar limits
colorbar;
end
Please help me to accomplish this! Thanks very much for any help!
BW
Jasper
0 件のコメント
回答 (1 件)
Adam
2016 年 4 月 29 日
編集済み: Adam
2016 年 4 月 29 日
You may want/need to create your own colourmap, but just use
caxis([0 1])
or whatever the full range across all your plots would be for every plot rather than setting the caxis range to cover the data in the individual plots. If you do this then that range will always map to the full colourmap.
If you use [0 1] range for every plot then e.g. yellow will always be between 0 and 0.1 irrespective of whether a given plot has data there and your boundary of e.g. 0.25 will map to the same colour in both plots.
I have never used pcolor so I don't know if it has any special properties that make this not work, but for things like imagesc which I usually use it should be fine so I assume for pcolor too.
4 件のコメント
Adam
2016 年 4 月 29 日
編集済み: Adam
2016 年 4 月 29 日
c1 = [1 0 0];
c2 = [0 1 0];
c3 = [0 0 1];
for i = 1:3
c(1:200,i) = linspace( c1(i), c2(i), 200 );
c(200:256,i) = linspace( c2(i), c3(i), 57 );
end
for example, would create a colourmap that graduates from red to green over 200 samples, then green to red over the remaining 56 samples of the colourmap.
Obviously you could extend it to as many colour points as you wish. You also don't have to restrict yourself to 256-sized colourmap either.
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!