Change colorbar scale, but keep zero value white
66 views (last 30 days)
Show older comments
Heidi Hirsh
on 14 Aug 2019
Commented: Jess Lovering
on 15 Aug 2019
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 Comments
Jess Lovering
on 14 Aug 2019
I ran your test script and it looks like it worked OK for me. The zero values were white on my plot.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!