08-16-2012 03:51 PM
I have a 2D array of data, and I would like to plot a histogram.
each row(with 8 elements) would be plotted in pairs, in 2 different colours.
My chart would have to look something like the attached image.
My vi is also attached. Right now it displays the plot (one row for now),but I have a few problems:
1) How to change the colour of each bar (to be like the excel graph)
2) how to change the bar plot label ( so instead numeric values 1,2,3,...I would like to have a,b,c,... under each bar)
3)and how to remove the (0,0) point on the graph, so you could see the first bar entirelyy, instead of partially.
I tried bundling the data , dynamic data, and a a bunch of other things but couldnt get it to work.
Thanks!!
08-17-2012
05:03 PM
- last edited on
04-30-2025
03:42 PM
by
Content Cleaner
You can create a histogram of each row by connecting the output of the General Histogram or Histogram VI's (in the Statistics Palette) to a Build Array. Connect the output of Build Array to a Histogram Graph. You can create a Histogram Graph by right clicking on the General Histogram or Histogram VI's Histogram Graph output terminal( Create>>Indicator). That should show you both histograms with different colors in one graph(they may be overlapping though, use the Bar Plots options to see what view is best). Unfortunately, I don't see how you could display it like the graph you posted, but you may create a button that controls a Histogram Graph by using Property Nodes. Right click on the Histogram Graph indicator in the Block Diagram(Create>>Property Node>>Plot>>Visible). If you connect a Boolean control to this property node and place that piece of code inside a while loop, you could turn your plots on and off. You can also create an Invoke Node(Right Click>>Create>>Invoke Node>>Export data to Excel) to Export data to Excel. Make sure you expand the Plot Legend on the upper right corner so you can see the second plot options.
Here are some links that might be helpful:
https://www.ni.com/docs/en-US/bundle/labview/page/customizing-graphs-and-charts.html
https://forums.ni.com/t5/LabVIEW/Can-labview-display-a-histogram-plot-of-data/td-p/971038
I hope this helps.
08-21-2012 01:21 PM
Thanks!
When I use the histogram.vi, the x and y axis it uses are not what I need- is there a way to flip them around?
or is there a way I can configure my input data to get the same reuslts?
I need the bin values to be the x axis.
Thanks!
08-21-2012 02:06 PM
You're welcome!
You can try clicking on the upper right hand side pictures next to the histogram labels on your Histogram Graph. You will see a set of options:
-In Common Plots, you may use the last two options( second row)
-In Bar Plots, you may chose any of the options in the last 2 rows. Here you can select having vertical or horizontal bars.
You probably want to select the hollow bars with spacing to avoid being confused by the overlaps. Also try right clicking on the graph near the x-axis to adjust the scale. Good luck!
08-21-2012 02:47 PM
I still cant fix the over lapping problem. I tried your suggestions but I cant get it to work.I've attached a new version of my program, that display 2 different coloured plots. I need to see both bars at the same time, since they are two different levels for one input.
Any help is appreciated!
08-21-2012 04:39 PM
Hello again. Unfortunately, I don't believe the bars can be displayed side by side. You may be able to see "pulses" side by side by changing the common plot to the 5th option. I see you did that already, but I can't see your second histogram(I disabled the blue one and I can't see it). I would use the general histogram VI once I have the 1D arrays for each data set. Create an indicator from one of the general histogram VIs and disconnect it( you will use this in the end as your graph). Create a new 2D array of waveforms from the output of each general histogram VI. Connect the output of this last array to the "indicator(histogram graph)" you had created. If this isn't acceptable, you can work with the exported data. Good luck
08-22-2012 11:40 AM
Thanks!
I tried Connecting the output of this last array(the 2d array I assume) to the indicator(histogram graph) I had created, however I cannont, since the input is a 2d array and it is expecting a cluster of 2 elements..I have attached my code with this change, it is at the botom of the main loop...
Thanks again!
08-22-2012 01:15 PM
Hello developer001!
You should connect the Histogram Graph output of each Histogram VI into the Build Array terminals instead of the Histogram output. You'll notice these are clusters now. Therefore, the Build Array will have the required data type.
Good luck!