Change the markers color in the figure after plotting

33 visualizaciones (últimos 30 días)
BN
BN el 8 de Dic. de 2021
Editada: DGM el 8 de Dic. de 2021
Dear all,
I used this function in Matlab FEX to draw a Taylor diagram. I really need to change the color of generated markers to some hex colors. Since this function won't accept hex color I want to ask you professionals Is there any way to change the color of each marker to hex colour after I draw? I hope Matlab could save my life again.
load('taylor_data.mat');
% Calculate statistics for Taylor diagram
% The first array element corresponds to the reference series for the
% while the second is that for the predicted series.
taylor_stats1 = taylor_statistics(pred1,ref,'data');
taylor_stats2 = taylor_statistics(pred2,ref,'data');
taylor_stats3 = taylor_statistics(pred3,ref,'data');
% Store statistics in arrays
sdev = [taylor_stats1.sdev(1); taylor_stats1.sdev(2); ...
taylor_stats2.sdev(2); taylor_stats3.sdev(2)];
crmsd = [taylor_stats1.crmsd(1); taylor_stats1.crmsd(2); ...
taylor_stats2.crmsd(2); taylor_stats3.crmsd(2)];
ccoef = [taylor_stats1.ccoef(1); taylor_stats1.ccoef(2); ...
taylor_stats2.ccoef(2); taylor_stats3.ccoef(2)];
% Produce the Taylor diagram.
%
% Note that the first index corresponds to the reference series for the
% diagram. For example sdev(1) is the standard deviation of the reference
% series and sdev(2:4) are the standard deviations of the other series.
% The value of sdev(1) is used to define the origin of the RMSD contours.
% The other values are used to plot the points (total of 3) that appear in
% the diagram.
[hp, ht, axl] = taylor_diagram(sdev,crmsd,ccoef);
I want to change red circules to 3 different colors using hex colors.
Thank you all.

Respuesta aceptada

DGM
DGM el 8 de Dic. de 2021
Editada: DGM el 8 de Dic. de 2021
This should be a start
load('taylor_data.mat');
% Calculate statistics for Taylor diagram
taylor_stats1 = taylor_statistics(pred1,ref,'data');
taylor_stats2 = taylor_statistics(pred2,ref,'data');
taylor_stats3 = taylor_statistics(pred3,ref,'data');
% Store statistics in arrays
sdev = [taylor_stats1.sdev(1); taylor_stats1.sdev(2); ...
taylor_stats2.sdev(2); taylor_stats3.sdev(2)];
crmsd = [taylor_stats1.crmsd(1); taylor_stats1.crmsd(2); ...
taylor_stats2.crmsd(2); taylor_stats3.crmsd(2)];
ccoef = [taylor_stats1.ccoef(1); taylor_stats1.ccoef(2); ...
taylor_stats2.ccoef(2); taylor_stats3.ccoef(2)];
% Produce the Taylor diagram.
[hp, ht, axl] = taylor_diagram(sdev,crmsd,ccoef);
% convert a hex tuple
hexcolor = 'FE230A';
deccolor = hex2dec(reshape(hexcolor,[],2)).'/255
for kc = 1:numel(hp)
set(hp(kc),'MarkerFaceColor',deccolor,'MarkerEdgeColor',deccolor)
end
If you want to have a different color for each marker, you can just move the conversion process inside the loop.

Más respuestas (1)

Bjorn Gustavsson
Bjorn Gustavsson el 8 de Dic. de 2021
You should be able to change the color of the points by using the hp output:
set(hp(1),'color',[0.95,.3,0.1])
set(hp(2),'color',[0.32,0.1,0.9])
set(hp(3),'color',[0.1,1,0.43])
Check the help and documentation of the function for more information.
HTH

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by