boxplot with different array size
Show older comments
Is there any way to print boxplot for different columns size in x-axis?
Answers (1)
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:
Categories
Find more on Box Plots 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!