LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Histogram with fixed interval size

Hi Dear All,


I need to build a histogram and what I want to achieve is all histograms to have fixed width. But I can't control the width of bins and they have different width at graph.

I have two arraysin one stored the number of itemsin another count of each item.


I have read this article as wellbut have not succeed.

http://forums.ni.com/t5/LabVIEW/histogram-interval-size/m-p/879242/highlight/true#M397722

 

Please take a look on attached picture and vi.


Any help will be appreciated,
Thanks in advance.
 

Download All
0 Kudos
Message 1 of 8
(5,172 Views)

Hello Tigran,

 

If you want equal sized bins your item array has to be equispaced as well. This is because the elements of item array are taken as the centre point of the bin and the width is decided by the difference between 2 consecutive elements of item array. Since your item array has 100 and 101 the bin size of those 2 bins is the minimum.

 

While giving the input you should ensure that your item array is equispaced event though the corresponding count is 0. You can do this programmatically as well. The easiest way to do this is to always assume bin size as 1 and therefore always give the item array as 90, 91, 92, 93....112, with corresponding count array as 20,0,0,0...10. 

 

A more involved method can be to determine the minimum bin size at run time. This can be the greatest common denominator of the differences between the consecutive elements of the item array. For example, if your item array is 90,94,98,102,114, then the consecutive differences will be 4,4,4,12. The GCD of these differences will be 4. Therefore the maximum bin size can be 4. Therefore you should change your item array to 90,94,98,102,106,110,114 before plotting.

 

Hope this helps.

 

Regards,
Chinmay

Chinmay Anand Misra
CLD
Technical Marketing Engineer
NI IndRA
Message 2 of 8
(5,135 Views)

Hello Chinmay,


Thank you for detailed answer.


But in case if I create equispaced array I will get graph with some blank space there between vertical bars. What I want to get is something like excel histogram. Please take a look to attached .PNG.
Also this way will increase array size which I want to escape.


So is there any plotting way to get histogram like in excell?

Thank you again.

0 Kudos
Message 3 of 8
(5,124 Views)

Tigran,

 

You also might want to check out the second post on this thread

Message 4 of 8
(5,093 Views)

Hi TigranMinasyan,

 

you could feed an equidistant surrogate for the not-equidistant Item Array, like this:

 

Unbenannt.png

 

 

Moreover, Ben showed us in the following thread how to use a Picture Indicator to create custom x-axis labels:

http://forums.ni.com/t5/LabVIEW/Is-there-a-way-to-make-table-entries-vertical-rather-than/m-p/416881...

 

 

Regards,
Alex

Message 5 of 8
(5,082 Views)
Message 6 of 8
(5,072 Views)

Thank you all for your help and effort, I really appreciate it!!!

 

I have tried surrogate solution before posting question. But it doesn't work for me as I need to have zoom, on a graph. And when I am zooming I need to change the X-axis picture.

 

All this stuff is kind of workarounds 😞 It is sad that LabView does not offer direct way to plot histograms with custom X-axis data.
I hoped, that there will some special type of histogram or any way to configure regular one to get plot not homogeneous X axis data, which I am not aware, but as I see there is no way.

 

Thanks to All,
Tigran

0 Kudos
Message 7 of 8
(5,054 Views)

TigranMinasyan wrote: It is sad that LabView does not offer direct way to plot histograms with custom X-axis data.

 

 have you seen this post?

https://forums.ni.com/t5/LabVIEW/3D-Stem-Graph-String-based-Axes/m-p/2592609#M779623

 

custom-labels-3d.png

0 Kudos
Message 8 of 8
(5,012 Views)