Increasing the line width of box plot whiskers
I have written some code to produce 2 boxplots side by side using tiledlayout. I would like to increase the line weight of the boxes and the whiskers and have written the code to do so as follows:
figure()
t = tiledlayout(1,2,’tilespacing’,’none’);
nexttile
boxplot(T_toPlot,’BoxStyle’,’outline’,’Color’, ‘b’, ‘Symbol’,’xk’, ‘OutlierSize’,8,’Labels’, labels);
bx1 = findobj(‘Tag’,’boxplot’);
set(bx1.Children,’LineWidth’,2)
h = findobj(gca,’Tag’,’Box’);
for j=1:length(h)
patch(get(h(j),’XData’),get(h(j),’YData’),get(h(j),’Color’),’FaceAlpha’,.5);
end
clear h j
nexttile
boxplot(S_toPlot,’BoxStyle’,’outline’,’Color’, ‘b’, ‘Symbol’,’xk’, ‘OutlierSize’,8,’Labels’, labels);
bx2 = findobj(‘Tag’,’boxplot’);
set(bx2.Children,’LineWidth’,2)
h = findobj(gca,’Tag’,’Box’);
for j=1:length(h)
patch(get(h(j),’XData’),get(h(j),’YData’),get(h(j),’Color’),’FaceAlpha’,.5);
end
clear h j
The first time I run this code, the first tile runs successfully and I get the following error message for the second tile:
Error using matlab.graphics.primitive.Line/set
Invalid parameter/value pair arguments.
Error in Filename (line XXX)
set(bx2.Children,’LineWidth’,2)
If I then do nothing, just hit enter again to re-run the cell, it then fails with the same error, but now for the first tile – and does not reach the second tile. Even if I clear the workspace and re-run the data processing from scratch, subsequent re-runs will fail for the first tile unless I restart the program. How can I increase the line weight of the boxplots (particularly the whiskers) without running into this problem? Thanks!I have written some code to produce 2 boxplots side by side using tiledlayout. I would like to increase the line weight of the boxes and the whiskers and have written the code to do so as follows:
figure()
t = tiledlayout(1,2,’tilespacing’,’none’);
nexttile
boxplot(T_toPlot,’BoxStyle’,’outline’,’Color’, ‘b’, ‘Symbol’,’xk’, ‘OutlierSize’,8,’Labels’, labels);
bx1 = findobj(‘Tag’,’boxplot’);
set(bx1.Children,’LineWidth’,2)
h = findobj(gca,’Tag’,’Box’);
for j=1:length(h)
patch(get(h(j),’XData’),get(h(j),’YData’),get(h(j),’Color’),’FaceAlpha’,.5);
end
clear h j
nexttile
boxplot(S_toPlot,’BoxStyle’,’outline’,’Color’, ‘b’, ‘Symbol’,’xk’, ‘OutlierSize’,8,’Labels’, labels);
bx2 = findobj(‘Tag’,’boxplot’);
set(bx2.Children,’LineWidth’,2)
h = findobj(gca,’Tag’,’Box’);
for j=1:length(h)
patch(get(h(j),’XData’),get(h(j),’YData’),get(h(j),’Color’),’FaceAlpha’,.5);
end
clear h j
The first time I run this code, the first tile runs successfully and I get the following error message for the second tile:
Error using matlab.graphics.primitive.Line/set
Invalid parameter/value pair arguments.
Error in Filename (line XXX)
set(bx2.Children,’LineWidth’,2)
If I then do nothing, just hit enter again to re-run the cell, it then fails with the same error, but now for the first tile – and does not reach the second tile. Even if I clear the workspace and re-run the data processing from scratch, subsequent re-runs will fail for the first tile unless I restart the program. How can I increase the line weight of the boxplots (particularly the whiskers) without running into this problem? Thanks! I have written some code to produce 2 boxplots side by side using tiledlayout. I would like to increase the line weight of the boxes and the whiskers and have written the code to do so as follows:
figure()
t = tiledlayout(1,2,’tilespacing’,’none’);
nexttile
boxplot(T_toPlot,’BoxStyle’,’outline’,’Color’, ‘b’, ‘Symbol’,’xk’, ‘OutlierSize’,8,’Labels’, labels);
bx1 = findobj(‘Tag’,’boxplot’);
set(bx1.Children,’LineWidth’,2)
h = findobj(gca,’Tag’,’Box’);
for j=1:length(h)
patch(get(h(j),’XData’),get(h(j),’YData’),get(h(j),’Color’),’FaceAlpha’,.5);
end
clear h j
nexttile
boxplot(S_toPlot,’BoxStyle’,’outline’,’Color’, ‘b’, ‘Symbol’,’xk’, ‘OutlierSize’,8,’Labels’, labels);
bx2 = findobj(‘Tag’,’boxplot’);
set(bx2.Children,’LineWidth’,2)
h = findobj(gca,’Tag’,’Box’);
for j=1:length(h)
patch(get(h(j),’XData’),get(h(j),’YData’),get(h(j),’Color’),’FaceAlpha’,.5);
end
clear h j
The first time I run this code, the first tile runs successfully and I get the following error message for the second tile:
Error using matlab.graphics.primitive.Line/set
Invalid parameter/value pair arguments.
Error in Filename (line XXX)
set(bx2.Children,’LineWidth’,2)
If I then do nothing, just hit enter again to re-run the cell, it then fails with the same error, but now for the first tile – and does not reach the second tile. Even if I clear the workspace and re-run the data processing from scratch, subsequent re-runs will fail for the first tile unless I restart the program. How can I increase the line weight of the boxplots (particularly the whiskers) without running into this problem? Thanks! boxplot, matlab MATLAB Answers — New Questions









