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

4 ビュー (過去 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 Center および File ExchangeLabels and Annotations についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by