필터 지우기
필터 지우기

How to define Matlab colors

조회 수: 3 (최근 30일)
SEVAL DONERTAS
SEVAL DONERTAS 2019년 1월 2일
댓글: Walter Roberson 2019년 1월 6일
Hi,
I have updated my matlab code in version 2018a Matlab. But when I try to execute this updated code in Matlab 2009a version; this error occurs:
Bad property value found.
Object name: line
Property name: 'Color'
The error occurs in the below Matlab line:
set([hline1; hline2], {'color'}, {'[0, 0, 1]';'[1, 0, 0]';'[0, 1, 0]';'[1, 1, 0]';'[0, 0.75, 0.75]';'[0.75, 0, 0.75]';'[0.635, 0.0780, 0.1840]';'[0.8500, 0.3250, 0.0980]';'[0.25, 0.25, 0]'; '[0.25, 0.25, 0.3]';'[0.25, 0.25, 0.5]';'[0, 0, 0]'});
By the way; I must use 12 colors to plot my figure. So I have defined the colors as in the above line..
How can I solve this problem?
  댓글 수: 3
SEVAL DONERTAS
SEVAL DONERTAS 2019년 1월 2일
편집: Walter Roberson 2019년 1월 2일
My full code;
f
igure;[haxes,hline1,hline2] = plotyy(dat_s1,[M1K1_norm_1 M1K2_norm_1 M1K1_norm_2 M1K2_norm_2 M1K1_norm_3 M1K2_norm_3 M1K1_norm_4 M1K2_norm_4], dat_s1,[T1 T2 T3 T4]);
set(haxes(1),'XLim',[T1A T1B],'Linewidth', 1.5);
set(haxes(2),'XLim',[T1A,T1B]);
set(haxes(1),'YLim',[0 1.3], 'FontSize', 16);
set(haxes(1),'YTick',[0:0.13:1.3]);
set(haxes(2),'YLim',[-60 90], 'FontSize', 16);
set(haxes(2),'YTick',[-60:15:90])
set(hline1,'LineWidth',3);
set(hline2,'LineWidth',3);
set(haxes, 'FontSize',15,'LineWidth',2)
set([hline1; hline2], {'color'}, {'[0, 0, 1]';'[1, 0, 0]';'[0, 1, 0]';'[1, 1, 0]';'[0, 0.75, 0.75]';'[0.75, 0, 0.75]';'[0.635, 0.0780, 0.1840]';'[0.8500, 0.3250, 0.0980]';'[0.25, 0.25, 0]'; '[0.25, 0.25, 0.3]';'[0.25, 0.25, 0.5]';'[0, 0, 0]'});
Walter Roberson
Walter Roberson 2019년 1월 6일
Please do not close questions that have an answer. The volunteers spend time researching and answering questions, and it is not fair to the volunteers when their work suddenly disappears.

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

채택된 답변

Walter Roberson
Walter Roberson 2019년 1월 2일
If you are going to set with character vectors then you need to use color names or the color abbreviations such as 'b'.
When configuring numeric values, do not use '' around the value.
set([hline1; hline2], {'color'}, {[0, 0, 1]; [1, 0, 0]; [0, 1, 0]; [1, 1, 0]; [0, 0.75, 0.75]; [0.75, 0, 0.75]; [0.635, 0.0780, 0.1840]; [0.8500, 0.3250, 0.0980]; [0.25, 0.25, 0]; [0.25, 0.25, 0.3]; [0.25, 0.25, 0.5] ; [0, 0, 0]});
Note that this will give you an error unless [hline1; hline2] together refers to 12 handles for primitive line objects. Each primitive line object can have only one Color value. It is not possible to configure multiple colors for a single primitive line object.
  댓글 수: 2
SEVAL DONERTAS
SEVAL DONERTAS 2019년 1월 2일
But when I run this code in version 2018a; there is no problem. When I run in 2009a version, I come across error. Can be a problem related to version mismatch?
Walter Roberson
Walter Roberson 2019년 1월 2일
No, it is a bug in your code that you have been unlucky to not have noticed before. There is no documented meaning for using character vectors of numeric values to define colors. Anything could happen.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by