# how to plot to get four plots of descriptive statistics in one figure

18 views (last 30 days)
gjashta on 19 Jan 2020
Commented: dpb on 22 Jan 2020
I have attached the descriptive statistics of 4 different zones below.
Can you help me how to get the four plots in one figure?

dpb on 19 Jan 2020
You haven't kep the underlying data in the summary statistics so can't do the histogram from those statistics alone. It's simple enough to use subplot and the example at <Histogram + PDF Plot>. Presuming you have the Statistics Toolbox, it's much simpler to use normpdf and fplot to generate the theoretical pdf curve than having to write the solution manually, however.
For the general idea, can generate a random sample and use it in lieu of the actual data...
hAx=gobjects(4,1);
for i=1:4
hAx(i)=subplot(2,2,i);
mn=desc1{1,i+1};
sd=desc1{2,i+1};
histogram(randn(1000,1)*sd+mn,'Normalization','pdf');
hold on
z=mn+linspace(-3,3);
plot(z,normpdf(linspace(-3,3)))
end
results in gjashta on 20 Jan 2020
I have used also histogram(rawData(:,i),'Normalization','pdf'); But still I got the error: Brace indexing is not supported for variables of this type.
dpb on 20 Jan 2020
"I have used also histogram(rawData(:,i),'Normalization','pdf');"
That looks fine by itself; I had no problem with the barebones
figure, for i=1:4,subplot(2,2,i),histogram(rawData(:,i),'Normalization','pdf');end
at the command line, so you've got something else going on in the code you're actually trying to run.
Without the identical code and the error message in context of the session in which it's run, can't say what nor where your error is...but, it will work if you go through very carefully and make sure you're addressing a table variable with the curlies "{}" to return the underlying data as double and the array of doubles with ordinary parentheses.
I will note these data are all strongly bi-modal; a single normal won't fit the data worth anything. They're also strongly skewed to the right like maybe lognormal or extreme value or similar... dpb on 20 Jan 2020
How could you possibly do that??? What's to plot? All you have is a set of point statistics and for such a data set, single point measures would appear to be almost meaningless.
What is the end point you're trying to reach?

dpb on 20 Jan 2020
Edited: dpb on 20 Jan 2020
Revised to use the real data and the fitted statistics...as noted above, you can't represent these distributions at all fairly by a simple single-moded distribution nor summary set of statistics... Code that produced these:
hAx=gobjects(4,1);
for i=1:4
hAx(i)=subplot(2,2,i);
mn=desc1{1,i+1};
sd=desc1{5,i+1};
mnm=desc1{10,i+1};
mxm=desc1{11,i+1};
h=histogram(rawData(:,i),'Normalization','pdf');
hold on
z=linspace(mnm,mxm);
plot(z,normpdf(z,mn,sd))
end

Show 1 older comment
dpb on 21 Jan 2020
You named your script plot which aliased the builtin MATLAB plot() function...which when you then tried to call the latter, is now defined to be a script (that you're executing so if it weren't for the syntax error, you just built an infinite recursive loop) instead of the builtin.
clear plot
then rename your script to something NOT a MATLAB function name and try again...
I'd repeat the Q? I asked above, however...what's the end objective here other than the simplistic one of plotting some data?
The data are bimodal and RH skewed; single-point measures are of virtually no meaning to describe them. What are you trying to accomplish?
gjashta on 22 Jan 2020
Hi dpb! Sorry for the late reply! My objective here is just to describe and understand the features of this data.
dpb on 22 Jan 2020
Well, visualization is obviously the first key...if you had simply looked only at the summary statistics computed, you'd have a totally different idea, probably.
"Describing" can mean a lot of things; what's the end result of this description to serve to do?
Where do the data come from; looks like should be a relatively easy fitting problem for a combination of two unimodal distributions but unless one knows what generated the bimodal result whether that's the appropriate model is yet unknown.