Choose automatic use of colour in plot

조회 수: 12 (최근 30일)
Lukas Bathelt
Lukas Bathelt 2017년 2월 7일
답변: Walter Roberson 2017년 2월 7일
hey guys, I have a problem with the plot instruction. Usually, when I type
figure
hold on
plot(x_1,y_1)
plot(x_2,y_2)
I will get a plot with two lines in different colors. I don't know what happend but it's not running with my Matlab version scince a few weeks. I'm using Matlab R2014a. When I type this code I get a plot with two lines and both lines are blue. I know that I can choose the colour in the plot enviroment with
plot(x_1,y_1,'r')
but I want that the color's chosen automatically.
Is there anyone who has an idea what I can do?

채택된 답변

Walter Roberson
Walter Roberson 2017년 2월 7일
This is a difference that came in from R2014b onwards. The R2014a and earlier equivalent is
hold all

추가 답변 (1개)

Shih-Hsuan Yuan
Shih-Hsuan Yuan 2017년 2월 7일
I can think of 2 ways to help you.
1.
plot(x_1,y_1,x_2,y_2);
Simplest way.
Or if you want some sort of controls over the color. You can download this function. Basically this function generate random distinguishable colors for you.
color_data = distinguishable_colors(2);
plot(x_1,y_1,color_data(1,:);
plot(x_2,y_2,color_data(2,:);
Or you can use to colormap function in MATLAB. It will do similar thing for you.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by