How to change the mean value in the box plot?

조회 수: 7 (최근 30일)
Lilya
Lilya 2016년 5월 19일
댓글: dpb 2016년 5월 21일
Hi all, I want to replace the mean value in the boxplot to the RMSE. as figure illustrates.
Thank you in advance
  댓글 수: 3
Lilya
Lilya 2016년 5월 19일
Sorry. the figure is uploaded. Yes, I want to marker the RMSE value in the boxplot instead of the mean(or median) value.
dpb
dpb 2016년 5월 19일
A boxplot marker is the median, NOT the mean...
To change this, you'll have to edit the box plot properties; there's a discussion in the help of finding the proper object via findobj and Tag values for the various options...

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

채택된 답변

the cyclist
the cyclist 2016년 5월 19일
편집: the cyclist 2016년 5월 19일

Here is an example of what dpb is proposing to do:

x = randn(1000,3);
figure
boxplot(x)
h = findobj(gca,'Tag','Median');
set(h,'Visible','off');

Notice that I have found the lines that are tagged as "Median", and turned off their visibility.

Now, you could add a marker or line (or whatever) to indicate the RMSE.

  댓글 수: 5
Lilya
Lilya 2016년 5월 20일
Actually, the reason is to make the compared RMSE of the data clear enough to understand with respect to the whole set. Mr. Cyclist, I did as you did but the calculated RMSE number is not illustrated in the plot. Could you please help me again? thank you
dpb
dpb 2016년 5월 20일
편집: dpb 2016년 5월 20일
Don't just tell us what you did, show the code itself in question.
Actually, after Cyclist's fixup, perhaps scatter would be the trick--
hold on
hS=scatter(1:3,0.5*rand(1,3),'filled');
Ayup, that puts a marker in the near-middle of the three boxen; text could label it as well...
ADDENDUM
Actually, to do this, it would be better to delete the line mean objects and add the scatter points or replace the '[x|y]yData' properties of the mean line and set the marker style as wanted instead of just making them invisible. There's no sense in keeping unused objects hanging around.

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

추가 답변 (1개)

dpb
dpb 2016년 5월 20일
Building off of Cyclist's demo and the comments I made earlier--
x = randn(1000,3);
boxplot(x)
h = findobj(gca,'Tag','Median');
set(h,{'xData'},{[1];[2];[3]}, ...
{'yData'},{[0.1];[0.2];[0.3]}, ...
'marker','*','color','k')
NB: the use of cell arrays to set multiple handles to disparate values in a single call to set. For demo I used hardcoded values but they can be variable, of course, and mat2cell can be helpful to build the proper shape.
  댓글 수: 2
Lilya
Lilya 2016년 5월 20일
I really appreciate it. Thanks very much
dpb
dpb 2016년 5월 21일
No problem, glad to help... :)
BTW, you can eliminate the temporary handle variable array by folding findobj into set...
set(findobj(gca,'Tag','Median') ...
{'xData'},{[1];[2];[3]}, ...
{'yData'},{[0.1];[0.2];[0.3]}, ...
'marker','*','color','k')
Like the objects themselves if not being used, I dislike keeping unneeded temporaries...

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

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by