How do I get rid of the dotted lines when using multcompare?

1 view (last 30 days)
I want to use a figure from multcompare in a paper, I want to get rid of the vertical dotted lines that show the interval of convergence.
y = [52.7 57.5 45.9 44.5 53.0 57.0 45.9 44.0]';
g1 = [1 2 1 2 1 2 1 2];
g2 = {'hi';'hi';'lo';'lo';'hi';'hi';'lo';'lo'};
g3 = {'may';'may';'may';'may';'june';'june';'june';'june'};
[~,~,stats] = anovan(y,{g1 g2 g3},'model','interaction',...
'varnames',{'g1','g2','g3'});
results = multcompare(stats,'Dimension',[1 2])

Accepted Answer

Adam Danz
Adam Danz on 9 Sep 2019
[results,~,h] = multcompare(stats,'Dimension',[1 2]); %return 'h', the figure handle
axh = gca(h); % get the axis handle
axh.XLimMode = 'Manual'; % if you don't do this, the xlim will change when lines are removed
axh.YLimMode = 'Manual'; % if you don't do this, the ylim will change when lines are removed
refLineHandles = findobj(axh.Children,'LineStyle', ':'); % find the handle to the ':' lines
delete(refLineHandles) % delete those lines
  4 Comments
Michael Werthmann
Michael Werthmann on 5 Jul 2021
Hello Adam,
I have a different question. I actually want to plot all the vertical dotted lines for all groups and not just the one I clicked on. Is that possible. Can I then change the colours to the same colour for all?
Kind Regards
Michael
Adam Danz
Adam Danz on 6 Jul 2021
You can use xline(__,'k:','Alpha',.2) to add vertical lines. You just need to determine the x-value for the line.

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!