How to change the marker symbol on the plots generated by anovan function?

For example:
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])
Would give me a plot like this:
ThreeWayANOVAMultipleComparisonsExample_02.png
How would I change those circle markers to dots?

 Accepted Answer

The third output of multcompare is the figure handle of the figure it drew into. Assuming that you call that fig
ch = fig.Children(1).Children(); %children of the axes
marker_handles = ch(2:2:end);
Now you can
set(marker_handles, 'Marker', '.')
Unfortunately the dots will be nearly invisible unless you increase the marker size -- and if you do that, then you are essentially just doing a filled circle marker and instead of changing marker shape you should consider something similar to
set(marker_handles, {'MarkerFaceColor'}, get(marker_handles, 'Color'))

5 Comments

This works, thank you!
How did you know that the marker handles were ch(2:2:end)? Is there a way to see where the property handles are of a figure?
Once I had the figure it was easy to examine children of it to see there was one axes. With the axes it was easy to see it had a series of line objects ss children. I assigned those to a variable, ch, and started querying the properties by displaying ch(1) and ch(2) and so on. I could see from there that the odd numbered children were the visible lines and that the even numbered ones were single points to draw markers.
The most difficult part was figuring out the syntax to do the setting of the marker edge color in bulk instead of having to loop: that syntax is always obscure!
is it possible to color each row of the above plot with a specific color like color coding?
To change the marker size:
set(marker_handles, {'MarkerSize'}, num2cell(Vector_Of_New_Sizes))
Vector_Of_New_Sizes must have the same length as the number of marker handles.
Note: in the special case where you are setting them all to the same size then
set(marker_handles, 'MarkerSize', New_Size)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!