boxplot with different array size

3 views (last 30 days)
feras almasri
feras almasri on 13 Mar 2015
Answered: Ayush on 4 Dec 2024
Is there any way to print boxplot for different columns size in x-axis?

Answers (1)

Ayush
Ayush on 4 Dec 2024
Hi,
You can create boxplots for different columns with varying sizes on the x-axis by using the “boxplot” function. To adjust the x-axis for different column sizes, you can use the “Positions” property to specify the positions of the boxes along the x-axis. Refer to an example code below for a better understanding:
% Sample data
data = randn(100, 3); % 100 samples for 3 different columns
% Specify the positions for each boxplot
positions = [1, 3, 5]; % Adjust these values to change the spacing
% Create the boxplot
figure;
boxplot(data, 'Positions', positions);
% Customize the x-axis
xticks(positions);
xticklabels({'Column 1', 'Column 2', 'Column 3'});
xlabel('Columns');
ylabel('Values');
title('Boxplot with Different Column Sizes on X-axis');
For more information on the “boxplot” function refer to the below documentation:

Community Treasure Hunt

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

Start Hunting!