Change color of a box in BOXPLOT

26 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 20 de Mzo. de 2014
Respondida: MathWorks Support Team el 20 de Mzo. de 2014
I want to change the color of the box in my boxplot. How can I do it?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 20 de Mzo. de 2014
Refer to the following example for changing the box color
% Create the boxplot
x1 = normrnd(5,1,100,1);
x2 = normrnd(6,1,100,1);
figure;
boxplot([x1,x2]);
% Change the boxplot color from blue to green
a = get(get(gca,'children'),'children');   % Get the handles of all the objects
t = get(a,'tag');   % List the names of all the objects 
box1 = a(7);   % The 7th object is the first box
set(box1, 'Color', 'g');   % Set the color of the first box to green

Más respuestas (0)

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by