I need to make a box plot, I am stuck making more than one

I have a time series of numbers 15 min averages of 50 hours. So this is 200 points and need a box plot of every hour, so 4 points for one box plot. Can anyone help with this?

 Respuesta aceptada

boxplot(reshape(date(4,[]))
or, somewhat less cryptic perhaps if you are using an actual timeseries object with calendar times would be to group by day and use the optional second grouping argument to boxplot. Or, of course, since the grouping is fixed and known, you could also create the grouping vector manually.

9 comentarios

Thank you for your reply. I am getting an error Too many input arguments. I don't have a time series. I just need that one boxplot has 4 points in it.
how would I group four points and then next plot is four points?
Need to see what you actually did; seems to work ok here--
data=randn(200,1);
boxplot(reshape(data,4,[]))
results in
"and then next plot is four points?"
If you really intended to have 50 separate figures, then just iterate over the columns after reshape-ing the vector to array.
[Answer moved to Comment -- dpb]
It works now thank you. A follow up question is if I can use this with plotty? eg. put mean velocity on the other y axis (on the right) to see if it lines up?
It would be 50 points on the right hand y axis that goes on top of the 50 boxplots, is this possible?
Not with plotyy, no, boxplot doesn't have the proper footprint of (x,y) arguments required. plotyy has been deprecated after the introduction of yyaxis, however, in part owing to this limitation I'm sure.
yyaxis left; hAxL=gca; % get handle; yyaxis doesn't return is bad design
boxplot(....
yyaxis right; hAxR=gca; % ditto
plot(x,y)
ylim(hAxL.Ylim) % match up ylim to scale same
linkaxes([hAxL hAxR],'xy') % keep in synch
Salt to suit...
[USE COMMENTS for other than actual ANSWER to problem -- dpb]
I' m not sure I have yyaxis - can I download this function?
yyaxis left;
hAxL=gca; % get handle; yyaxis doesn't return is bad design
boxplot(reshape(fluxO2tom01and23,4,[]));
yyaxis right; hAxR=gca; % ditto
plot(o_optode_mean1,1:196)
ylim(hAxL.Ylim); % match up ylim to scale same
linkaxes([hAxL hAxR],'xy'); % keep in synch
Undefined function or variable 'yyaxis'.
dpb
dpb el 6 de Ag. de 2018
Editada: dpb el 8 de Ag. de 2018
It's relatively new; R2016a. AFAIK there's no publicly available substitute for the exact syntax.
But, you can "fake it"...
boxplot(reshape(data,4,[])) % create the boxplot for starters
hAx=gca; % hang on to this axes handle
yl=hAx.YLim; ytk=hAx.YTick; % and default range, ticks
hold on % let's not wipe this out
% now plot on top for RH with dummy placeholders for left
[hAx,hL1,hL2]=plotyy(nan,nan,mean(reshape(data,4,[])),'r*');
set(hAx,{'ylim'},{yl},{'ytick'},{ytk})
seems to duplicate effect.
Otherwise, it's not difficult to create the second axes manually if needs be...there's an example in the enhancing graphics section that shows how to do two axes from scratch. Multiple x- and y-axes

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 6 de Ag. de 2018

Editada:

dpb
el 8 de Ag. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by