# histogram of x and y data from a txt file

2 views (last 30 days)
masoud meskin on 29 Nov 2021
Commented: Star Strider on 29 Nov 2021
Hi guys!
The attached txt file contains the infromation of mesh quality generated in a CAD model. The 1st column represents the "skewness" and the 2nd column represents the "number of elements". How i can plot the histogram of the data, in which the x axis shows the skewness and y axis shows the number of elements, like the attached figure?
Thank you
Masoud

Star Strider on 29 Nov 2021
It seems to produce the correct result on its own!
T1 = 400×2 table
Var1 Var2 ________ ____ 0.024316 0 0.024316 1 0.033988 1 0.033988 0 0.033988 0 0.033988 0 0.04366 0 0.04366 0 0.04366 0 0.04366 4 0.053332 4 0.053332 0 0.053332 0 0.053332 139 0.063005 139 0.063005 0
figure
plot(T1{:,1}, T1{:,2})
Adjust the available options to produce the desired result.
Another possibility —
figure
fill(T1{:,1}, T1{:,2}, 'r')
Experiment to get the desired result.
.
##### 2 CommentsShowHide 1 older comment
Star Strider on 29 Nov 2021
As always, my pleasure!
.

Image Analyst on 29 Nov 2021
Looks like Star's answer is what you're looking for. I just wanted to say that skewness is the third central moment of a distribution (histogram), so that histogram you have will also have a skewness related to how lopsided/skewed the distribution is. A symmetrical distribution (e.g. a Normally distributed population) would have a skewness of 0. If it's skewed left it would have a negative skewness and if it's skewed right it would have a positive skewness.
I've heard of the skewness of a histogram but I've never heard of a histogram of skewnesses, though it's possible. For example you could read in 400 images and compute the distance between an actual (x,y,z) coordinate on the 3-D printed (or blow molded) physical object, and the desired (x,y,z) coordinate of the CAD model, and then get a histogram of the distances and compute the skewness of the disance errors for each image (CAD file) (based on it's histogram), then you could get a distribution of those skewnesses (over all CAD files), where the bin value is the skewness and the y value is the count.
What's puzzling me is that none of your skewnesses are more than 1, or less than 0. I mean, I guess it could happen, like if your distributions were just very slightly lopsided to the right, though the huge spikes near (but not exactly at) 1 are also puzzling.
So I just wanted to make sure that you're getting your skewnesses correct and you really have a distribution of skewnesses and not some other type of distribution, like distribution of gray levels, or particle sizes, or distance deviations between physical model and CAD model, or whatever.
##### 2 CommentsShowHide 1 older comment
Image Analyst on 29 Nov 2021
Seems to me "perfect" would be if the cellsize was the optimalcellsize so the numerator was 0 and the skew value would be 0, not 1. If the cell size was 0, it seems like that would be bad and the skew would be 1, and if the cell size was huge, like 2*optimalcellsize, then the skew would be -1. So it seems like a histogram might have a hump centered around zero if most of the cell sizes were near optimal.

### Community Treasure Hunt

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

Start Hunting!