LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot visibility checkbox for an errorbar plot

Solved!
Go to solution

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. 
 

SudiptaDas_3-1687887881406.png

 

 

This is how it looks like in the front interface panel:

SudiptaDas_1-1687887759856.png

Generally, in waveform plots there remains a property called "Plot Visibility" which can be accessed from the property node e.g. the following:

SudiptaDas_4-1687888071103.png

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):

SudiptaDas_5-1687888198887.png


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.

0 Kudos
Message 1 of 7
(1,151 Views)

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

0 Kudos
Message 2 of 7
(1,106 Views)

@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:

  1. Start by making a copy of vi.lib\Math Plots\2D Math Plots\2D Error Bar, since you don't want to modify the existing copy. Add all of things there into a new wrapping library, so that they have their own namespace and don't conflict with the built-in version. I think the actual mods only need to be made to 2D Error Bar.lvclass and 2D Error Bar.xctl, so you could possibly only take those folders, but I also see that some of the properties in the classes are defined as protected, so I'm guessing that won't work.
  2. Go to the Facade VI of the XControl. This is the UI element you actually see. I don't think you need any changes there, but it's good to understand.
  3. The good news for you is that the code already includes the plot visible boolean and it's already connected to the graph property, so all you need to do is add support for it in Legend Palette.vi, which is the UI for the properties. You could also add a property for the XControl if you want to modify it programmatically. I'll leave the implementation as an exercise for you.

___________________
Try to take over the world!
0 Kudos
Message 3 of 7
(1,093 Views)

@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:

 

BertMcMahan_0-1687966377583.png

 

 

@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.

0 Kudos
Message 4 of 7
(1,063 Views)

@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.


___________________
Try to take over the world!
0 Kudos
Message 5 of 7
(1,042 Views)

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: 

SudiptaDas_0-1688070477548.png

 

SudiptaDas_1-1688070492290.png

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. 

0 Kudos
Message 6 of 7
(1,024 Views)
Solution
Accepted by topic author SudiptaDas

@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!

0 Kudos
Message 7 of 7
(1,020 Views)