Change colorbar scale, but keep zero value white
76 次查看(过去 30 天)
显示 更早的评论
I am trying to plot positive data as red (darker red=higher magnitude) and negative data as blue. I want zero to be white. I am using the bluewhitered function to color the data because I could not have another colormap that did this in the matlab choices. But since my data include much higher positive magnitudes than negative values. The negatives look dark blue even at low magnitude. I think the function must make the max and min data values the darkest color end points. I tried to force the negative data to show up lighter blue by using caxis to limit the colors from -0.5 to +0.5 but then zero is not white for some reason. Do you have another idea for a similar color map or a way to fix this one?
I have attached the first plot and my attempted fix.
Here's my code:
f1=figure(1)
pcolor(MX,PK.mab,PK.fixdeltaPH);
shading('interp');
colormap(bluewhitered);
ylabel('Depth (mab)','fontsize',16);
c=colorbar();
%caxis([-0.5 0.5]); % This did not fix it because zero is not white now
ylim([0 6])
title(c,'\DeltapH','fontsize',16);
set(gca,'fontsize',16);
x = datenum('July-23-2018'):7:datenum('Oct-5-2018');
set(gca, 'XTick', x);
datetick('x','mm/dd','keepticks')
3 个评论
Jess Lovering
2019-8-14
I ran your test script and it looks like it worked OK for me. The zero values were white on my plot.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!