Borrar filtros
Borrar filtros

How to set the colors and numbers of a colorbar to special values

1 visualización (últimos 30 días)
Behrad Ze
Behrad Ze el 28 de Ag. de 2022
Respondida: Walter Roberson el 28 de Ag. de 2022
Dear Experts,
I am using matlab to plot a series of surfaces with different maximum and minimum Z values, I want to set the maximum and minimum of all the plots to specific numbers and specific colors, to be able to compare the surfaces easily. For example, set my limits to the range (-7 to -27),and set its colors(blue -7, white 0, and red 27) for all plots. Some of my plots may not reach to these limits, However, I also want to apply this rule for them, therefore matlab selects the color automatically based on the color rules mentionaed above (for example the attached sample file can not reach to the limitations).I am using the code as below
csvfiles = dir('*.csv');
for file = csvfiles'
sample=readmatrix(file.name);
x=sample(1,2:end);
y=sample(2:end,1);
dataSample=sample(2:end,2:end);
figure();
graph=surf(x,y,dataSample);
xlim([400 4000])
ylim([400 4000])
zlim([-7 27])
set(graph,'LineStyle','none');
title(file.name)
colormap('turbo');
colorbar();
view(2);
end
Any help in this regard will be highly appreciated.
Best Regards,

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Ag. de 2022
use caxis() to manually set the range of numbers that colors are mapped from

Categorías

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

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by