Filter löschen
Filter löschen

COLOR CODE IN MULTIPLE PLOT

3 Ansichten (letzte 30 Tage)
Grace
Grace am 27 Aug. 2022
Kommentiert: Grace am 28 Aug. 2022
Hi everyone, I inted to to make a multiple plot with with predefined color code.
Could you please assit me, on how to include the code to define the colors of my plot instead of using the matlab default color
clear all; close all; clc
a=[6.5 10 12 16];b=linspace(1, 10);
for i=1:4;
aa=a(i)
y=1./(exp(-aa./b)+ 1);
plot(b, y)
hold on
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Aug. 2022
If you are using a new enough version of MATLAB, see colororder
If you are using an older version of MATLAB, you could change the ColorOrder property of the axes.
Or... each time you plot() you could pass in a 'Color' option with the color you want. For example,
cmap = jet(4);
a=[6.5 10 12 16];b=linspace(1, 10);
for i=1:4;
aa=a(i)
y=1./(exp(-aa./b)+ 1);
plot(b, y, 'color', cmap(i, :), 'DisplayName', string(i));
hold on
end
aa = 6.5000
aa = 10
aa = 12
aa = 16
legend show
  5 Kommentare
Walter Roberson
Walter Roberson am 27 Aug. 2022
cc = {'.r', '-k', '--g', ':b'};
a = [6.5 10 12 16]; b = linspace(1, 10);
for i=1:4;
aa=a(i)
y=1./(exp(-aa./b)+ 1);
plot(b, y, cc{i}, 'DisplayName', string(i));
hold on
end
aa = 6.5000
aa = 10
aa = 12
aa = 16
legend show
Grace
Grace am 28 Aug. 2022
Thanks a million times

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by