How do I change the colormap so that it begins with zero and increases with positive numbers ? Now I am using the colormap with the spectrogram function and it has negative numbers.

How do I change the colormap so that it begins with zero and increases with positive numbers ? Now I am using the colormap with the spectrogram function and it has negative numbers. I want the dark blue to be zero and the dark red to be the largest number.
figure1=figure
[y,f,t,p] =spectrogram(accf(:,20),.03*size(acc,1),round(0.9*.03*size(acc,1)),[],1/dt,'yaxis'); surf(t,f,10*log10(abs(p)),'EdgeColor','none'); axis xy; axis tight; colormap(jet); view(0,90); ylim([0 10])

Answers (1)

You can use
caxis([0 35])
to set the colormap axis limits from 0 to 35.

2 Comments

I did exactly that and I the plot becomes saturated with blue
figure1=figure [y,f,t,p] =spectrogram(accf(:,20),.03*size(acc,1),round(0.9*.03*size(acc,1)),[],1/dt,'yaxis'); surf(t,f,10*log10(abs(p)),'EdgeColor','none'); axis xy; axis tight; colormap(jet); view(0,90); caxis([0 35]) ylim([0 10])
That's because your data is negative, which is why it initially came up with negatives in the colormap. If you set it to all positives, like 0-35, and you don't have any data in that range (like you don't), then you will get all one color. What used to be blue at -70 is now blue at 0, and since your data is all less than zero, it shows up as blue, which is the first color in the colormap and is the color that applies to data values less than the first caxis value. Anything more than 35 would show up as red (but you don't have any data more than 35 so you don't see any red).
Does that make sense now?

Sign in to comment.

Asked:

on 4 Feb 2016

Commented:

on 4 Feb 2016

Community Treasure Hunt

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

Start Hunting!