필터 지우기
필터 지우기

How can I change the color of the median line in boxchart?

조회 수: 25 (최근 30일)
omid zandi
omid zandi 2021년 7월 12일
이동: Cris LaPierre 2024년 4월 8일
I am creating a box plot using the "boxchart" function. How can I change the color of the median line?

채택된 답변

Star Strider
Star Strider 2021년 7월 12일
It is not possible to change the colours, however it is possible to over-plot the median lines —
x = randn(5); % Create Data
figure
hbx = boxchart(x);
xMdn = median(x);
boxw = hbx.BoxWidth;
xd = 1:numel(hbx.XData);
hold on
plot(0.5*boxw*[-1;1]+xd, [1;1]*xMdn, '-r')
hold off
% get(hbx)
.
  댓글 수: 6
Amelie
Amelie 2024년 4월 8일
이동: Cris LaPierre 2024년 4월 8일
I have a follow up question: Is it possible to exclude the median when plotting the boxchart? If so, how can I do it?
Many thanks for your help!
Star Strider
Star Strider 2024년 4월 8일
이동: Cris LaPierre 2024년 4월 8일
@Amelie
I’m not certain it can be excluded, however it can be hidden —
x = randn(5); % Create Data
figure
hbx = boxchart(x);
hbx.BoxMedianLineColor = 'g'; % Change 'boxchart' Median Line Colour
figure
hbx = boxchart(x);
hbx.BoxMedianLineColor = 'none'; % Hide 'boxchart' Median Line
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by