I want to move up my boxchart
Show older comments
I want to move up my boxchart a little bit. I want it to have two boxes for 0min right next to eachother, also for the other 3 exposure times right next to eachother. So, you will still have 4 catogories, but for every catagorie two boxes next to eachother. Because, it is a little bit hard to see now. Thank you!

%% Glass Ra
clear all, close all;
glass = xlsread('excelsensofarglass')
glass2 = xlsread('excelsensofarglass2')
glass3 = xlsread('excelsensofarglass3')
glass4 = xlsread('excelsensofarglass4')
glass5 = xlsread('excelsensofarglass5')
glass6 = xlsread('excelsensofarglass6')
G1 = [transpose(glass(1:4,1));transpose(glass2(1:4,1));transpose(glass3(1:4,1));transpose(glass4(1:4,1));transpose(glass5(1:4,1));transpose(glass6(1:4,1))]
G2 = [transpose(glass(6:9,1));transpose(glass2(6:9,1));transpose(glass3(6:9,1));transpose(glass4(6:9,1));transpose(glass5(6:9,1));transpose(glass6(6:9,1))]
G4 = [transpose(glass(11:14,1));transpose(glass2(11:14,1));transpose(glass3(11:14,1));transpose(glass4(11:14,1));transpose(glass5(11:14,1));transpose(glass6(11:14,1))]
G6 = [transpose(glass(16:19,1));transpose(glass2(16:19,1));transpose(glass3(16:19,1));transpose(glass4(16:19,1));transpose(glass5(16:19,1));transpose(glass6(16:19,1))]
figure(1)
hold on
% boxchart(G1)
boxchart(G2)
boxchart(G4)
% boxchart(G6)
ylim([0 1.6])
ylabel('Arithmetic average height [\mum]')
xlabel('duration of exposure')
title('Arithmetic average height glass')
legend('20 [\mum]','40 [\mum]','location','northwest')
set(gca,'XTickLabel',{'0min','60min','90min','240min'})
Accepted Answer
More Answers (2)
Cameron
on 4 Jan 2023
I'm not sure if there is a way to do that. You can always use this instead.
% Left axes
ax1 = nexttile;
boxchart(ax1,G2)
set(ax1,'XTickLabel',{'0min','60min','90min','240min'});
% Right axes
ax2 = nexttile;
boxchart(ax2,G4)
set(ax2,'XTickLabel',{'0min','60min','90min','240min'});
the cyclist
on 4 Jan 2023
It doesn't seem to me that the code you pasted could create the plot example you've posted (but maybe I'm misunderstanding something). Can you upload your G1, G2, ... data? (You can use the paper clip icon in the INSERT section of the toolbar.)
Without understanding more, my best suggestion would be instead of using the
boxchart(ydata)
syntax, use
boxchart(xgroupdata,ydata)
and give the two groups you want to separate slightly different x values (e.g. [-1,1], [-59 61], etc), so that they are offset from each other.
Categories
Find more on Timetables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



