# histogram of x and y data from a txt file

2 views (last 30 days)

Show older comments

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

##### 0 Comments

### Accepted Answer

Star Strider
on 29 Nov 2021

It seems to produce the correct result on its own!

T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/817474/mesh_histogram.txt', 'VariableNamingRule','preserve')

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 Comments

### More Answers (1)

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 Comments

Image Analyst
on 29 Nov 2021

### See Also

### Community Treasure Hunt

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

Start Hunting!