LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Histogram Help

Solved!
Go to solution

Hi,

I need help creating a histogram of some data.
I want to create a histogram where:

x-axis=Letter Grade (A, B, C, D, F)
y-axis= number of students got each of the letter grade.

This is part of a project i am working on at the moment. Please look at the attached file and help me at your earliest convenience. 

In this project, i needed to calculate the course average, assign each student a grade, and rank them based on their course average. At last i need to create a histogram of distribution. I tried Histogram sub-VI, and histogram from the probability menu. Couldn't get it to work. Any help would be greatly appreciated.

Capture.PNGCapture.PNG

0 Kudos
Message 1 of 10
(4,322 Views)
Solution
Accepted by topic author Alyssa001

Unfortunately you cannot use text as the x-axis scale. You can either use 0 1 2 3 4 and know that it means A B C D F, or hide the tick mark labels completely and just put text boxes where they need to go.

 

You have your bins defined already, all you need to do is count how many are in each bin. Here is one way to do that using the in place element structure:

 

Capture.png

0 Kudos
Message 2 of 10
(4,307 Views)

Thank you for your reply. This is my first labview course and i have never used the in place structure. Also, it is a little difficult for me to implement on my program. Is there any other simple way i can do this? Like using the Histogram Subvi or something else? Thanks again.

0 Kudos
Message 3 of 10
(4,300 Views)

Also, if you can please do problem similar to mine. If not, i totally understand. 

0 Kudos
Message 4 of 10
(4,299 Views)
Solution
Accepted by topic author Alyssa001

I think gregory's solution is probably what you want.

Here's an example that might be a little clearer:

HistogramXY.png

To set the graph with that appearance, I clicked the icon at the top right and chose the plot style from the Bar Plot subsection (perhaps you already knew this - it was something I just learned 🙂 )

Here I'm basically just plotting a bundle of an array of X and an array of Y values, where X = {0, 10, 20, ...} and Y is the number in that decade.

 

If you want to have non-even interval sizes, you should look at Threshold 1D Array, but this would take quite a bit more work handling fractional behaviour and making the graph look nice...


GCentral
0 Kudos
Message 5 of 10
(4,280 Views)

Which array function are you guys using inside the in place element structure? @greogoryj @cbutcher. Index array?

0 Kudos
Message 6 of 10
(4,255 Views)

Thank you. I was able to figure it out. Really appreciate the help 🙂

Capture.PNG

0 Kudos
Message 7 of 10
(4,247 Views)
Solution
Accepted by topic author Alyssa001

As an alternative, you could use variant attributes for the counting and use an array of clusters (grade, count) as indicator. Here's a quick draft. It will even tell you if there are unexpected letter grades (e.g. lower case grade, grade with a space or linefeed afterwards, etc.). The input is the array after your first loop.

 

(Also note that in your original code, you could combine the last two FOR loops into one for simplicity. Also the first two loops can be combined. You could even include the code of my second loop into your first loop)

 

Histogram_CA.png

0 Kudos
Message 8 of 10
(4,233 Views)

Note: Of course there is no "D" grade, so change code accordingly. Sorry about that. I fixed and re-attached 😄

 


@altenbach wrote:

 

(Also note that in your original code, you could combine the last two FOR loops into one for simplicity. Also the first two loops can be combined. You could even include the code of my second loop into your first loop)

 


Histogram_CA2.png

 

Here's how this could look like.

Message 9 of 10
(4,231 Views)

Thank you sir. I really appreciate the help 🙂
I learned a lot from this forum,  specially from you @altenbach 🙂

0 Kudos
Message 10 of 10
(4,213 Views)