Borrar filtros
Borrar filtros

How to label a colormap

9 visualizaciones (últimos 30 días)
Daniel
Daniel el 2 de Sept. de 2012
I would like to label a colormap with text to indicate what it represents, and the min and max values. My plots come out inconsistant and repeat the labels I want. For example, I might want the min value on the bottom of a vertical colormap, the max value at the top and the word 'Trec' in the middle. Here is my code to date but the colorbar produced shows from top to bottom: "Trec -50 40 Trec -50" instead of the desired "50 Trec -40"
colormap(jet); %defines bype of color map for points in scatter plot
cmin = -50; cmax = 40; V=[cmin, cmax];
caxis(V); %set color map range
subplot(2,1,1) %scatter plot
scatter(newData1.data(:,RH_TAM_col),newData1.data(:,RH_CIT_col),10,newData1.data(:,6))
hcb = colorbar('YTickLabel', {num2str(cmin),'Trec', num2str(cmax)}); %add colorbar scale to plot
set(hcb,'YTickMode','manual'); %colorbar handle hcb. Keep color bar labels from changing when resizing.
grid on

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Sept. de 2012
You need to set the YTick as well, or else the number of ticks will usually not match the number of labels you have provided.
Note: if you do supply YTick, then YTickMode will be set to 'manual' on your behalf.
  4 comentarios
Daniel
Daniel el 3 de Sept. de 2012
OK, thanks. I think I may have it working now. My new code:
colormap(jet); %defines bype of color map for points in scatter plot cmin = -50; cmax = 40; V=[cmin, cmax]; subplot(2,1,1) %scatter plot scatter(newData1.data(:,RH_TAM_col),newData1.data(:,RH_CIT_col),10,newData1.data(:,6)) caxis(V); %set color map range hcb = colorbar('YTick', [cmin 0 cmax],'YTickLabel', {num2str(cmin),'Trec', num2str(cmax)}); %add colorbar scale to plot

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Blue en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by