How to change the mean value in the box plot?

Hi all, I want to replace the mean value in the boxplot to the RMSE. as figure illustrates.
Thank you in advance

3 Comments

Ms. O, this is not twitter. Can you please give a little more detail, to make what you are trying to do clearer? Maybe show an example plot and how you want it to be different?
For example, do you want the whole box shifted? Or do you mean that there is a marker at the mean, but you want to show a marker at the RMSE value?
Don't make all of us guess at what you want.
Sorry. the figure is uploaded. Yes, I want to marker the RMSE value in the boxplot instead of the mean(or median) value.
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...

Sign in to comment.

 Accepted Answer

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 Comments

dpb
dpb on 19 May 2016
Edited: dpb on 19 May 2016
What is the type of the marker, Cyclist? I presume it's an object with x,y position properties that can be queried like a scatter object or similar--if so would be able to reset the y value to match an externally computed RMSE value; wouldn't be kosher to just relabel the existing point.
I'm not sure OTOMH about interpreting this in the format of a boxplot; they've got a pretty universally-accepted definition as introduced but that's another issue besides the "how". Sometimes even if one can do something, it doesn't mean one should but perhaps there's some field in which this has become accepted practice???
Fun fact: Box plots were introduced by John Tukey, not George Box!
But to your main point ... I have to admit I am also puzzled about the info Ms. O plans to convey with the "RMSE version" of a box plot. I was hoping for some self-realization on her part after the mechanics of how this could be done were presented. In fact, there is no RMSE in the absence of some fit (or something like a fit), right? So, not quite sure where this is going.
Brain cramp...I knew that but for some reason fanned...I've got Tukey's book. Thanx for correcting history, though, mayhaps I'll edit the comment to remove that reference leaving only the ??? of "what are you thinking?". :)
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
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.

Sign in to comment.

More Answers (1)

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 Comments

I really appreciate it. Thanks very much
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...

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Asked:

on 19 May 2016

Commented:

dpb
on 21 May 2016

Community Treasure Hunt

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

Start Hunting!