10-08-2013 07:06 AM
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 arrays, in one stored the number of items, in another count of each item.
I have read this article as well, but 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.
10-09-2013 12:56 AM
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
10-09-2013 05:33 AM
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.
10-09-2013 01:48 PM
10-09-2013 04:33 PM
Hi TigranMinasyan,
you could feed an equidistant surrogate for the not-equidistant Item Array, like this:
Moreover, Ben showed us in the following thread how to use a Picture Indicator to create custom x-axis labels:
Regards,
Alex
10-09-2013 05:24 PM
10-10-2013 02:19 AM
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
10-16-2013 05:34 PM
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