How to set the colors and numbers of a colorbar to special values
조회 수: 1 (최근 30일)
이전 댓글 표시
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,
댓글 수: 0
답변 (1개)
Walter Roberson
2022년 8월 28일
use caxis() to manually set the range of numbers that colors are mapped from
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!