How to make a line plot with Jet colored lines?

조회 수: 45 (최근 30일)
MP
MP 2022년 8월 17일
댓글: MP 2022년 8월 18일
Hi everyone!
I would like to make a line plot of the attached data. There are about 64 different lines in the single plot.
So, I use the following command.
zz1.zz1 = load('z1.mat');
zz1.zz2 = load('x2.mat');
plot(zz1.zz2.X2_axis, zz1.zz1.Z2_axis)
I get the following attached figure.
Instead I want the lines to follow jet colorbar.
Something like
cmp1 = colorbar(jet(64));
plot(zz1.zz2.X2_axis, zz1.zz1.Z2_axis,'Color',cmp1);
But, this throws error!
Any help will be greatly appriciated.

채택된 답변

Chunru
Chunru 2022년 8월 17일
편집: Chunru 2022년 8월 17일
zz1.zz1 = load('z1.mat');
zz1.zz2 = load('x2.mat');
cmp1 = jet(64);
% Use colororder
colororder(cmp1);
plot(zz1.zz2.X2_axis, zz1.zz1.Z2_axis);
h=gca;
legend(h.Children, 'Location', 'Eastoutside', 'NumColumns', 2, 'FontSize', 6)
  댓글 수: 15
Chunru
Chunru 2022년 8월 18일
You can flip SN or h.Children. Alternatively, use a loop:
for i=1:size(zz1.zz1.Z2_axis, 2)
plot(zz1.zz2.X2_axis(:, i), zz1.zz1.Z2_axis(:,i), 'DisplayName', SN(i));
end
% Assume that SN is string array
MP
MP 2022년 8월 18일
Yes, that is perfect. @Chunru
Thank you very much.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by