MATLAB Answers

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

11 views (last 30 days)
Ebsa Eshete
Ebsa Eshete on 26 Jan 2020 at 1:41
Commented: Walter Roberson on 26 Jan 2020 at 6:03
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?

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Jan 2020 at 4:31
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'))

  2 Comments

Ebsa Eshete
Ebsa Eshete on 26 Jan 2020 at 5:45
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?
Walter Roberson
Walter Roberson on 26 Jan 2020 at 6:03
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!

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags


Translated by