Plotting data with min, max, mean value

24 views (last 30 days)
LamaObecna
LamaObecna on 10 Dec 2016
Commented: dpb on 12 Dec 2016
Hello, I need help with changing my output plot. I have computed data of temperature during whole year in one minute intervals. Plot of data looks like this:
Is there a way how to plot it and get graph for example like this one?
If it helps, I'm adding my simulated data. Thank you for any help.

Accepted Answer

dpb
dpb on 10 Dec 2016
Edited: dpb on 11 Dec 2016
See
doc boxplot % for starters...
ADDENDUM
I admit I've never used Matlab boxplot in anger; let's see...[ponder, piddle, ... ah, ok!]...
Takes a little klutzing around -- augment the shorter months with NaN to the length of the longest to create a rectangular array, then make a categorical grouping array 1:12 for each column.
ADDENDUM(2)
Decided to see if could do with your sample data...turns out not too bad...
g=ordinal(cellstr(datestr(datenum(2000,1:12,1),'mmm')));
l1=(eomday(2015,1:12))*24*60; % days in month for non-leapyear to minutes
l2=cumsum(l1); % cumulative for indexing into 1D vector
t=nan(31*24*60,12); % preallocate NaN
i1=1; % allocate to rectangular array...
for i=1:12
t(1:l1(i),i)=teplotaBojleru(i1:l2(i)).';
i1=l2(i)+1;
end
boxpot(t,g,'grouporder',cellstr(g))
NB: Remember I'm at R2012b; newer datetime class may be somewhat simpler. Also, if you could generate/retrieve the data initially in the orientation desired might make it a little simpler to not have to do the rearranging--altho it's not too bad...
ADDENDUM(3):
You don't have to rearrange; if you create a grouping variable of the same length as the vector that is the corresponding month for that column, then (other than perhaps memory issues) boxplot will work for that. I did a very trivial example of just 20 or so elements with three groupings to test the theory but it did work, apparently correctly.
The grouping for the categorical variable then needs must be
boxplot(x,g1,'grouporder',cellstr(getlevels(g1)))
to reflect the levels only since they're no longer unique as in the other method. I don't know how to manipulate the new categorical that seems missing these methods from the old Stat Toolbox implementation.
  9 Comments
dpb
dpb on 11 Dec 2016
Glad you did recognize the error...I realized my first response was incorrect when I checked my workspace and discovered I did have an 'l' array had forgotten about...
" what are those thick red lines?"
I dunno...I presume they're a fignewton of the result of the distribution of points from your artificial data but I don't really know what boxplot does internally or what it indicates, specifically, about that distribution/set of values.
I presume when you have real data it'll look more normal; certainly the time plot is kinda' funky-lookin' with the bounded/truncated distributions shown. Note that they show up on the two ends where you've truncated the bottom side so heavily.
dpb
dpb on 12 Dec 2016
" what are those thick red lines?"
Oh, I know! It's the gazillion "outliers" for those months that are so drastically truncated one side. Note for Jan how small the 25-75th percentile range is as compared to the actual data range. The default outlier symbol string is 'r+' so what looks solid is actually lots of red crosses on top of each other to make what looks like solid bar. You can just make out the vertical edge of the uppermost "+" at the top of each of those bars.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Preprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!