필터 지우기
필터 지우기

How can I label multiple boxplots with different symbols?

조회 수: 5 (최근 30일)
Jai Bhagat
Jai Bhagat 2017년 10월 22일
댓글: Daniel Bridges 2017년 11월 26일
In the 'boxplot' function, you are able to specify different colors for each boxplot. For example, if I have 4 boxplots, I can specify the colors as red, green, blue, and black for the boxplots using the Name-Value Pair 'colors', 'rgbk'.
Is there a way to do specify the symbol for each individual boxplot as well? Currently I am only able to change the symbol for all boxplots together.
- Jai
  댓글 수: 1
Daniel Bridges
Daniel Bridges 2017년 11월 26일
This seems useful for colorblind people, though I'm not sure why it's needed if the boxplots are labeled on the horizontal axis.

댓글을 달려면 로그인하십시오.

채택된 답변

Amy
Amy 2017년 10월 25일
Hi Jai,
Unfortunately it is not quite as simple to change the symbols for individual boxplots as it is to change the color.
However, it is possible to change the marker and color of the symbols for each boxplot by hand, after creating the boxplot. Here is an example of how to do so:
x1 = normrnd(5,1,100,1);
x2 = normrnd(6,1,100,1);
boxplot([x1,x2]);
a = get(get(gca,'children'),'children');
a(1).MarkerEdgeColor = 'g';
a(2).MarkerEdgeColor = 'b';
a(1).Marker = '*';
a(2).Marker = 'o';

추가 답변 (1개)

Jai Bhagat
Jai Bhagat 2017년 10월 25일
Ah, thanks so much Amy! Was wondering how to set properties of individual boxplots - I guess the 'children' of 'children' approach makes sense since the boxplot is a group variable and the children of the boxplot are lines.

Community Treasure Hunt

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

Start Hunting!

Translated by