# Does anyone know how to create colors?

3 views (last 30 days)
Pul on 16 Aug 2021
Commented: Pul on 17 Aug 2021
Hello everyone,
How can I create/ have different colors from the standard ones (i.g. 'g','r','b','m'...)?
Thank you.
##### 2 CommentsShowHide 1 older comment
Pul on 17 Aug 2021

Bjorn Gustavsson on 16 Aug 2021
Colours can be specified by rgb-values in a 1-by-3 array with values between zero and one. So for example:
light_blue = [0.5 0.5 1];
plot(0:12,randn(1,12),'color',light_blue)
HTH
Pul on 17 Aug 2021
@Bjorn Gustavsson Okay, thank you!

Image Analyst on 16 Aug 2021
Try this:
% Create 20 different colors according to the jet color map.
colors = jet(20);
% Plot randome data, each curve with one of the colors we created.
% Basically you have to get the color equal to one row from colors.
for k = 1 : size(colors, 1)
thisColor = colors(k, :);
y = rand(1, 5) + 2 * k; % Create some random data.
plot(y, '.-', 'Color', thisColor, 'LineWidth', 4, 'MarkerSize', 50); % Plot this one curve.
hold on; % Don't let subsequent plots blow away this one we just drew.
end
grid on;
xlabel('X');
ylabel('Y');
Pul on 17 Aug 2021
@Image Analyst Yes, clear, I got it.
Thank you!