06-27-2023 12:55 PM
Hi,
In the following code inside a state machine (started from the template), I am trying to plot some data in array format using an errorbar plot. You may notice in this code, I am accessing some of the properties from the property node to be set inside the for loop.
This is how it looks like in the front interface panel:
Generally, in waveform plots there remains a property called "Plot Visibility" which can be accessed from the property node e.g. the following:
In the errorbar plot, this seems missing. I am wondering if there is a way to implement a plot visibility checkbox that might look like the following (following is not my implementation):
IMP: I am using LV2021 32 bit
I am still relatively new to LV, so I must have missed something obvious. I would deeply appreciate any suggestion or help from you.
Thank you in advance.
Solved! Go to Solution.
06-27-2023 07:50 PM
Please attach your LabVIEW code (*.vi, no pictures!). If you are developing with a LabVIEW Project, compress the Project Folder and attached the resulting .zip file.
We need to be able to clearly see what you are attempting to do. Can you describe (in words) what you mean by "an errorbar plot" and what you would like to see and not-see?
Bob Schor
06-28-2023 01:12 AM
@SudiptaDas wrote:In the errorbar plot, this seems missing. I am wondering if there is a way to implement a plot visibility checkbox ...
Yes, but not without some work.
The error bar plot is an XControl with some classes for data management and it doesn't seem to have this feature. It does wrap a standard graph, which does have this, so it is possible to modify it to do this.
I haven't actually tried this, but it should look something like this:
06-28-2023 10:42 AM - edited 06-28-2023 10:44 AM
@Bob_Schor wrote:
Please attach your LabVIEW code (*.vi, no pictures!). If you are developing with a LabVIEW Project, compress the Project Folder and attached the resulting .zip file.
We need to be able to clearly see what you are attempting to do. Can you describe (in words) what you mean by "an errorbar plot" and what you would like to see and not-see?
Bob Schor
I think he means the native Error bar plot control:
@tst's solution is, unfortunately, a good one, I think. I say "unfortunately" because editing an Xcontrol is hardly a good place to get started for someone newer to LabVIEW. I also suspect that, since this Xcontrol wraps around a standard plot, there are actually multiple plots "under the hood" for each single "plot" that the user creates. This would mean that, for every "Plot visible" checkbox event that happens, at least two "actual" plots need to have their visibility toggled. I poked around in the Xcontrol a bit and it does seem like that's whats going on (though I'm not sure). Again, "unfortunately," you will have a bit more work to do figuring out how the errorbar plot's internal data works so you can toggle multiple plots with each checkbox toggle.
Another way to handle this would be to create your own plot legend, which would consist of a checkbox and string in a cluster, which is in an array. When the user clicks a checkbox, the whole plot is recalculated. This wouldn't give you all of the controlability of a standard plot legend, but it might be more work for someone not used to working on Xcontrols.
06-29-2023 02:17 AM
@BertMcMahan wrote:
@tst's solution is, unfortunately, a good one, I think. I say "unfortunately" because editing an Xcontrol is hardly a good place to get started for someone newer to LabVIEW.
Agreed. While the change seems relatively simple (I haven't dug around the control much beyond seeing that the property does already exist there), the combination of creating a copy and editing a class and an XControl is not what I would recommend to a relative beginner, although it is good in the sense that it can mimic actual work.
@BertMcMahan wrote:
Another way to handle this would be to create your own plot legend, which would consist of a checkbox and string in a cluster, which is in an array.
I'm not sure I understand your suggestion. If using the existing control, the XControl would have to be modified anyway, as that functionality isn't exposed outside of it. At that point, I think it would be easier to edit the existing dialog I pointed to, which already has examples of how this works, rather than recreating from scratch.
To be fair, my suggestion only talked about modifying the edit UI and I didn't talk about the legend, which I believe was an array of clusters in the XControl itself. I expect it would still be easier to modify that to include a checkbox than to build it from scratch.
Another entirely different option is to try to build the graph directly in a graph control instead of using the built-in XControl. I expect that's what the NI code is doing anyway. I haven't looked, but I believe I did see posts in the past with implementation of error bar graphs, so the code for this could probably be gotten either from the NI code or online.
Or it could be recreated, which is also a potentially useful exercise. The key pieces of info that would probably be useful for this are that if you hover over the BD terminal of an XY graph you can see the different data types it accepts and that if you graph a value that is NaN, it will not be displayed in the graph, allowing you to have separate elements in the graph. From there you can create a VI which will accept the relevant data and output something which can be fed into the graph. You can also use the annotation properties of the graph to display text.
It would also be possible to use the plot images properties to draw this in the graph, but that requires calling methods on the graph to translate the scale values to pixel coordinates and requires recalculation on zooming/panning/etc., so I don't think it's worth it, even if it might have some benefits.
06-29-2023 03:32 PM
Hello All,
Thank you so much for all your inputs. I did take a look at the XControl and it looked really daunting to me (I've a lot to learn). Also the idea to make a custom legend seems a little out of my reach. I, instead, have implemented a simpler solution for myself, which is not a direct solution to my original problem, merely a circumvention.
The idea is the following: there is an array of a cluster which consists of a boolean and a path control as the input. If a boolean is true corresponding to a path, the plot occurs, otherwise it does not:
The code (still incomplete) is attached below this time 🙂
I do appreciate all the discussion and wish it continues. I am unfortunately abandoning the fight because it's not really most crucial part of my project at the moment. I wish someone smarter than me can pick it up from here and bring it to the finish line.
06-29-2023 03:41 PM
@tst wrote:
@BertMcMahan wrote:
Another way to handle this would be to create your own plot legend, which would consist of a checkbox and string in a cluster, which is in an array.
I'm not sure I understand your suggestion. If using the existing control, the XControl would have to be modified anyway, as that functionality isn't exposed outside of it. At that point, I think it would be easier to edit the existing dialog I pointed to, which already has examples of how this works, rather than recreating from scratch.
I just meant make a legend outside of the Xcontrol. When a checkbox changes, just send all of the data WITH a check to the Xcontrol to be plotted. It didn't occur to me until just now that the plot colors would change, which would be super annoying. without doing a lot of extra plot handling (which I was trying to avoid).
It sounds like the OP got a temporary solution working though, so that's good news!