필터 지우기
필터 지우기

How to label Y_ticks for a multi line plot using a for loop

조회 수: 9 (최근 30일)
Reuben Addison
Reuben Addison 2022년 8월 25일
답변: Chunru 2022년 8월 26일
I am making a multiline plot however I want the y-tick labels to represent each iteration (i) in the loop, instead of just giving me 4 ticks. I need this to help me identify which signal number to remove in my preprocessing. Below is a sample data to recreate the plot.
channel_n = size(all_trials);
all_trials = ones([15,15]);
x_axis = linspace(-0.1, 0.3, length(all_trials));
for i = 1:channel_n(1)
figure(1)
plot(x_axis, abs(all_trials(:,i)) + 0.2*(i-1), 'b', 'linewidth',1.2), axis auto
title(name + "Waterfall Plot"')
hold on
end
hold off

채택된 답변

Chunru
Chunru 2022년 8월 26일
all_trials = randn(15, 15)*.1;
channel_n = size(all_trials, 2);
%all_trials = ones([15,15]);
x_axis = linspace(-0.1, 0.3, size(all_trials, 1));
figure(1); hold on
for i = 1:channel_n
plot(x_axis, abs(all_trials(:,i)) + 0.2*(i-1), 'b', 'linewidth',1.2), axis auto
end
title("Waterfall Plot"');
hold off
yticks((0:channel_n-1)*0.2)
yticklabels(string((0:channel_n-1)))

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by