How to use two seperate colorbars on the same plot.

Hello,
I am trying to make topographic map, using data from above and below the sea surface. I want to use two different colormaps, one for above the sea surface(positive z values) and one for below the sea surface(negative z values). Any help would be greatly appreciated.
Max

Respuestas (1)

Adam
Adam el 22 de Jun. de 2017
Editada: Adam el 22 de Jun. de 2017
You don't need two different colourmaps for that - you can join together two colourmaps yourself into a single one e.g.
cmap = [ summer(256); hot(256) ];
figure; imagesc( rand(100) - 0.5 );
colormap( gca, cmap );
You can do the same obviously with custom colourmaps or just create your own colourmap in any way you want.
You just need to ensure that you keep a symmetric colour range e.g.
clims = [-1 1] * max( abs( myData(:) ) );
caxis( hAxes, clims );
for some data, myData, and for an axes handle hAxes

2 comentarios

Max Campbell
Max Campbell el 22 de Jun. de 2017
Editada: Max Campbell el 22 de Jun. de 2017
Ok thanks.
The data range is from 100 to -5000. is it possible to make one colour map represent data above 0 and the other represent data below zero? I.e. to show a clear difference between land and sea. otherwise the transition is 2500m below the surface.
thanks
Adam
Adam el 22 de Jun. de 2017
You can play around with where you concatenate colourmaps if you wish, but it does get complicated - e.g. you can concatenate a colourmap of size 32 with a colourmap of size 128 to achieve an assymetric total colourmap, but you would have to work out the maths for what size you would need for each portion of the colourmap in that case.
in your case I guess you need the negative part of the colourmap to be 50 times bigger than the positive part if you fix the clims to [-5000 100]

Iniciar sesión para comentar.

Categorías

Preguntada:

el 22 de Jun. de 2017

Comentada:

el 22 de Jun. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by