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

3 次查看(过去 30 天)
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 中查找有关 Labels and Annotations 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by