How to define Matlab colors

2 visualizaciones (últimos 30 días)
SEVAL DONERTAS
SEVAL DONERTAS el 2 de En. de 2019
Comentada: Walter Roberson el 6 de En. de 2019
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 comentarios
SEVAL DONERTAS
SEVAL DONERTAS el 2 de En. de 2019
Editada: Walter Roberson el 2 de En. de 2019
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 el 6 de En. de 2019
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.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de En. de 2019
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 comentarios
SEVAL DONERTAS
SEVAL DONERTAS el 2 de En. de 2019
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 el 2 de En. de 2019
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by