How to define Matlab colors
조회 수: 2 (최근 30일)
이전 댓글 표시
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
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
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
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 Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!