How to modify Box Plot outliers marker size?? Can I insert a legend?

50 visualizzazioni (ultimi 30 giorni)
Hello community
I'm working with box plot, I built them using previous post related to the subject.
My main 2 problems here are:
How can I increase the size of the markers for outliers? Because when I'm doing my report is very difficult to see wich one in 'o' or 'x'.
Also, based in this code, how can I add a legend "group 1", "group 2" ?
Here is the code I'm using
clc
clear
load file1
var =file1;
x1 = var(1:124,1);
x2 = var(1:124,2);
x3 = var(1:124,3);
x4 = var(1:124,4);
x5 = var(1:124,5);
x6 = var(1:124,6);
x7 = var(1:124,7);
x11 = var(125:225,1);
x12 = var(125:225,2);
x13 = var(125:225,3);
x14 = var(125:225,4);
x15 = var(125:225,5);
x16 = var(125:225,6);
x17 = var(125:225,7);
x = [x1;x2;x3;x4;x5;x6;x7];
xx = [x11;x12;x13;x14;x15;x16; x17];
group_1 = [ones(size(x1)); 2*ones(size(x2)); 3*ones(size(x3));4*ones(size(x4)); 5*ones(size(x5)); 6*ones(size(x6)); 7*ones(size(x7))];
group_2 = [ones(size(x11)); 2*ones(size(x12)); 3*ones(size(x13));4*ones(size(x14)); 5*ones(size(x15)); 6*ones(size(x16)); 7*ones(size(x17))];
position1 = [2.325 3.325 4.325 5.325 6.325 7.325 8.325 ];
position2 = [2.575 3.575 4.575 5.575 6.575 7.575 8.575];
figure()
boxplot(x,group_1,'color','g','Widths',0.2,'positions',position1,'Symbol','o');
hold on
grid on
set(gca, 'fontweight', 'bold', 'box', 'on', 'fontsize', 18);
boxplot(xx,group_2,'color','r','Widths',0.2,'positions',position2, 'Symbol','x','Labels',{'0','1','2','3','4','5','6'});
set(findobj(gca,'type','line'),'linew',1.5)
xlabel('Days from Inoculation')
ylabel('Scores PCA 1')
ax = gca;
ax.XRuler.Axle.LineWidth = 2;
ay = gca;
ay.YRuler.Axle.LineWidth = 2;
hold off
  2 Commenti
the cyclist
the cyclist il 3 Lug 2019
I formatted your code using the CODE section. Please use that next time.
Would you be able to upload your file1, so that we can run your code and see exactly what you are seeing? That is sometimes more helpful than answering in the abstract.

Accedi per commentare.

Risposta accettata

the cyclist
the cyclist il 3 Lug 2019
Modificato: the cyclist il 3 Lug 2019
I think the following should work for you:
figure
boxplot(randn(1000,2))
h = findobj(gcf,'tag','Outliers')
set(ho,'MarkerSize',24)
Where I have written gcf, you should put your figure. (I was just using the current figure.)
I made the outliers huge, so the change is obvious. You can adjust the size with that parameter I set to 24.
You might have to adjust exactly how you do all this, given different number of boxes, outliers, etc, but you should get the gist.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by