필터 지우기
필터 지우기

How to plot like the inserted picture?

조회 수: 1 (최근 30일)
Aj
Aj 2019년 10월 23일
댓글: Aj 2019년 10월 24일
Hello guys,
I want to plot like the picture below in matlab:
Frage.PNG
Is it possible in Matlab?
In X-Axis is the Frequency.
Every row is a node and the colours are the values of the results.
  댓글 수: 2
Daniel M
Daniel M 2019년 10월 23일
Sure, you can use imagesc and then just play with the properties of the plot. In particular: YTick, YTickLabel, GridColor, GridAlpha, TickLength, YGrid, XMinorGrid, etc. etc. There are many to list. You can also manually add white lines if that's what you want.
Aj
Aj 2019년 10월 24일
Hello Daniel,
Imagesc worked well, thanks for that! You can see below the result. But now i have a other little question: I want to have yticklabels in a for loop:
for a=1:nfiles
yticks([a])
yticklabels({matfiles(a).name})
end
Only the last row has a label, but i want that all rows have a label.
Maybe you can help.
bild.PNG

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

채택된 답변

Daniel M
Daniel M 2019년 10월 24일
편집: Daniel M 2019년 10월 24일
You need to first collect all your values for yticks and labels, then set them all at once. For example
nfiles = 10;
for a = 1:nfiles
ticks(a) = a; % or whatever the ytick is
labels{a} = sprintf('Label %d',a);
end
figure
imagesc(magic(nfiles))
ax = gca;
set(ax,'YTick',ticks,'YTickLabel',labels);
set(ax,'YDir','normal')
Here is how you would add white lines.
x = [0.5 10.5]; % or however big your xaxis is
linelocs = [ticks(1:end-1) + 0.5]';
hold on
plot(x,[linelocs, linelocs],'w-','LineWidth',2)
And you can find the properties for the x-axis tick (length, colour, etc.) in here
xax = get(ax,'XAxis');
  댓글 수: 1
Aj
Aj 2019년 10월 24일
perfect, thank you very much!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by