How do I change colormap to match caxis?

4 views (last 30 days)
Lucy Cheadle
Lucy Cheadle on 28 Jul 2016
Edited: Walter Roberson on 28 Jul 2016
I have concentration data at various longitude and latitude (x = latitude, y = longitude, and C=concentration). I'm trying to use colormap to visually display the data but want to limit the range of the C values to [20 90]. I tried changing caxis and it changed the colorbar, but the map does not seem to be adjusting to match. Here is my code:
cdivs = 50;
[~, edges] = hist(C,cdivs-1);
edges = [-Inf edges Inf]; % to include all points
[Nk, bink] = histc(C,edges);
hold on
cmap = jet(cdivs);
caxis([20 90])
for ii=1:cdivs
idx = bink == ii;
plot(x(idx),y(idx),'o','MarkerSize',4,'Color',cmap(ii,:));
end
colormap(cmap)
c = colorbar;
c.Label.String = 'O3 (ppb)';
What am I doing wrong?

Answers (0)

Community Treasure Hunt

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

Start Hunting!