filling a 1D plot with colours associated to each sample value

조회 수: 6 (최근 30일)
hamed
hamed 2020년 9월 2일
댓글: hamed 2020년 9월 2일
I plotted a 1D signal in Matlab, and then I want to show the value of each specific sample by a district colour. something like what "imagesc" command does for 2D plots. I attached an example of what is in my mind. Any suggestions, please?

답변 (1개)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 9월 2일
편집: Abdolkarim Mohammadi 2020년 9월 2일
You can use patch() and use your response values for both edges and the color data. You replace your data with SampleX and SampleY.
SampleX = (1220:1250)';
SampleY = rand (numel(SampleX), 1);
PatchX = vertcat (SampleX, flip(SampleX));
PatchY = vertcat (SampleY, zeros(numel(SampleY),1));
ColorData = vertcat (SampleY, flip(SampleY));
patch (PatchY, PatchX, ColorData);
colorbar ();

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by