Change x- and y-axis description in multcompare()
Show older comments
Hi!
I am using multcompare() to plot the Tukey HSD Plot. Is it possible to change the description of the x- and y-axis and also change the title?

Accepted Answer
More Answers (2)
Zinea
on 3 Sep 2024
Yes, you can customize the axis labels and the title of a plot generated by the ‘multcompare’ function in MATLAB. Although this function itself does not directly provide options to change the axis labels or title, you can modify these properties after the plot is created using MATLAB's plotting functions.
Here is a complete MATLAB code which generates a dummy dataset, performs 'anova', followed by 'multcompare' and then changes the axis descriptions and the title:
% Generate a dummy dataset
% Assume we have three groups with different sample sizes
group1 = normrnd(5, 1, 10, 1); % Group 1 data: mean = 5, std = 1, n = 10
group2 = normrnd(6, 1, 15, 1); % Group 2 data: mean = 6, std = 1, n = 15
group3 = normrnd(7, 1, 12, 1); % Group 3 data: mean = 7, std = 1, n = 12
% Combine the data into a single vector
data = [group1; group2; group3];
% Create a grouping variable
group = [repmat({'Group 1'}, length(group1), 1);
repmat({'Group 2'}, length(group2), 1);
repmat({'Group 3'}, length(group3), 1)];
% Perform one-way ANOVA
[p, tbl, stats] = anova1(data, group);
% Perform Tukey's HSD test using multcompare
[c, m, h, gnames] = multcompare(stats);
% Customize the plot
xlabel('Mean Difference'); % X-axis label
ylabel('Group Comparisons'); % Y-axis label
title('Tukey HSD Test Results'); % Title
Output of above code:

Hope this helps you move forward!
Categories
Find more on Analysis of Variance and Covariance 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!