06-09-2021 04:08 AM - edited 06-09-2021 04:43 AM
Hello! I have a very simple problem but I am surprised it does not seem to have been addressed here.
I want to plot an intensity graph in real time from data generated within two for loops (I am scanning in XY and obtaining data at each point). The X and Y axes values are also generated within the for loops, and they are a function of the loop iteration but do not start from zero, (for example, the x axis might go from 50 to 70 and the y axis might go from 100 to 120).
Because the intensity graph only accepts a 2D array data type where the x and y indices are the x and y values on the intensity graph, this means that, although my data is only in a 20x20 area of the array, I need to initialize my array to be at least 70x120 given that the maximum y axis value is 120. This then poses problems when the data is plotted in the graph as it does not autosize properly.
How do I plot an intensity chart in real time with the correct axes values that does not require a much larger array than the data size???
Thank you in advance! (I am attaching an example which demonstrates my problem)
Solved! Go to Solution.
06-09-2021 04:24 AM - edited 06-09-2021 04:25 AM
You can use Property Node -->XScale/YScale--> Range --> Minimum/Maximum to set the limits of the chart.
EDIT: The VI you attached is empty...
06-09-2021 04:45 AM
This helps a lot with the plotting, thanks! I didn't know about property nodes but i do now!
However I still need to initialize a larger array than i need. Is there away to get around this? (If my X and Y values start at 1000 for example, it seems a waste to have to create a 1000x1000 array)
I've attached the file properly now! Sorry about that
06-09-2021 08:14 AM
It should be possible to set the Offset and Multiplier for the scales appropriately, so that your data ends up in a 30x20 array or whatever and the scales end up reading from 70-100 and 100-120.
See https://zone.ni.com/reference/en-XX/help/371361R-01/lvprop/clrgrphscl_ofst_multiofst/ for one of the properties.
You can adjust these to test quickly using the right click -> properties page for the graph (or the property node in an event structure and then controls for them to update with data already loaded, can be useful to explore how they work).
06-09-2021 08:25 AM - edited 06-09-2021 08:29 AM
Here's a snippet with that shown. I just indexed out of the loop for simplicity, but you could still do this with the Replace Array Subset (and an appropriately sized array, for the data, not the indices).
Here I just right clicked on the graph and chose to change the Offsets under the Scales (there's a dropdown for X and Y axes).
If you need to do it programmatically, there's the property node linked in my previous post.
The easy way to create these is to right click on the graph on the block diagram and then choose Create > Property Node > (scroll down lots) X Scale (or Y Scale, as appropriate) > Offset and Multiplier > Offset (or Multiplier, or all elements, in which case you get a cluster). Then right click on it and choose Change to Write (by default you get a Read property node, that tells you the current value). You can drag a Property Node downwards like I've done here to get multiple properties in one place (convenient for space on block diagram).
You can also modify the multiplier (the values are as you calculate using the "i" value in the loops previously), but since you're not using a different multiplier you can leave this at 1 (in this case).
06-11-2021 06:18 AM
Yes this is what I was after! Thanks - using a combination of this and the answer above it works 🙂