필터 지우기
필터 지우기

2D information to 1D colorplot

조회 수: 3 (최근 30일)
marie deseyn
marie deseyn 2019년 12월 10일
댓글: Adam 2019년 12월 10일
I want to plot a line (which can be a thick line) in which I plot for every x the temperature as the color, so I want a 1D graph in which the color says the temperature on that place, is that possible?
  댓글 수: 1
Adam
Adam 2019년 12월 10일
may help, if you are happy enough to have a surface object rather than a line object. It still looks like a line, just has surface properties so is a little less easy to do any further manipulations to if you need to.

댓글을 달려면 로그인하십시오.

답변 (1개)

darova
darova 2019년 12월 10일
Simple example
x = 0:10;
y = x.^2;
temp = rand(1,10); % temperature
cm = jet(10); % colormap
ind = 1+round(temp/max(temp)*9); % convert temperature to color index
figure(1)
hold on
for i = 1:length(x)-1
plot(x(i:i+1),y(i:i+1),'color',cm(ind(i),:))
end
hold off

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by