how to change colors of lines in a plot to exist on a scale

조회 수: 16 (최근 30일)
Em
Em 2021년 11월 27일
답변: DGM 2021년 11월 27일
Does anyone know how to change the colours of lines in a plot so that they exist on a scale?
My current code:
plot(powerpc,abs(depth70mms_02),powerpc,abs(depth70mms_03),powerpc,abs(depth70mms_04),powerpc,abs(depth70mms_05),powerpc,abs(depth70mms_06),powerpc,abs(depth70mms_07),powerpc,abs(depth70mms_08),powerpc,abs(depth70mms_09))
ylabel('Track Depth of 0.9 D.R. laser');
xlabel('Laser Power/mW');
Thank you!

답변 (1개)

DGM
DGM 2021년 11월 27일
What exactly do you mean by "on a scale"?
If what you're looking for is a means to have the line colors share a continuous colormap, then you can do that by setting the 'colororder' property of the parent axes.
N = 14; % number of lines in plot
% test data
x = linspace(0,1,100);
g = [1:N/2 1./(1:N/2)].';
y = x.^g;
% plot it
plot(x,y,'linewidth',2);
% pick some colormap and apply it to the colororder property
mycolortable = parula(N);
set(gca,'colororder',mycolortable)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by