LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control the order of plots

Solved!
Go to solution

When I plot multiple waveforms, or multiple traces on an XY plot, the final plot is "underneath" the ones that came before.  In LV 12.x, can I change the plot order, other than by changing the order of the elements in array used to make the plot?  (Changing the array order would not be desirable in my application.) I see from previous posts on this forum that the answer was "No" for LV 6.1, and that some creative but cumbersome workarounds were proposed.  Has this changed in the more recent versions of LV? Thank you.

Message 1 of 19
(6,311 Views)
Solution
Accepted by topic author WCR

Not that I can tell.  You still cannot programatically control the Z-axis order of the plots easilly.  I suspect you could do a custom user control digging fairly deep into the base xy graph but, there is a lot of under the hood magic in graphs that may be deep inside a component that is not publically available for messing with (in a DLL)

 

[Edit] opening the BD of a graph control shows a blank BD so the magic is deeper than we can get to without busting the base control type.  This is one feature to add to the Idea Exchange


"Should be" isn't "Is" -Jay
Message 2 of 19
(6,298 Views)

Thank you Jeff.

0 Kudos
Message 3 of 19
(6,292 Views)

I don't like to contradict someone much better at LabVIEW than me (actually, I do, when I know I'm right Smiley Wink ), but, Jeff, you're wrong here. It's easy, at least if you have a set number of plots (or less) on a graph. You don't have to do anything drastic to the basic graph indicator you pull off the palette at all.

 

The plotting order is set by the Active Plot number property. You can change that easily, and you can also change which data set is which Active Plot by changing the order in which the data sets are wired to the graph indicator (top - in front, bottom - in back). I've attached a simple demo of this, which is actually a stripped-down VI of one we use for our instruments, where only two plots are involved, but you could easily change it for more plots using a multiple-case structure and more wires.

 

(Boo, hiss, the forum software doesn't like to accept VIs again, so you'll have to replace the hyphen with a dot.)

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 4 of 19
(6,262 Views)

Hi Cameron,

 


by changing the order in which the data sets are wired to the graph indicator (top - in front, bottom - in back).


 

But just that the OP wanted to avoid!

 

We all know you have to change the array order to "move" plots up/down in the Z order! But we can't tell the graph to use array index 0 for plot 2...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 19
(6,260 Views)

Why can't we? Its a property node, you can wire anything to it you want. I'm not changing the order of the elements in the original array, I'm just making one array go to a different active plot number.

 

This disagreement seems to be a matter of interpretation of the OP's question to me. I am not messing with the data going to the plot at all, but pointing a specific data set (an array here, but could be done with an array column/row if the graph were organized differently) at the active plot number I wanted. I just took the VI I already had, threw out all the irrelevant stuff, and put in array constants for a simple demo. You could do the same thing by using Index Array to pull out single columns/rows from a 2D array and stuff them into clusters for the graph, deciding where in the order to put them with an enum, as I did in the attached VI here.

 

(Again, you'll have to change the hyphen to a dot after you download it to run it.)

 

How did you interpret the question differently?

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 6 of 19
(6,245 Views)

You are changing the order of the data in the array.  In one case the increasing straight line plot is white and listed as plot 0.  In another case, it is green and listed as plot 2.

 

The poster wants to change the "z-order" which is the order that the plots are drawn in the graph.  Plot 2 is drawn first in green.  The Plot 1 is drawn second in red.  If it overlays any green pixels, it turns red showing that plot 1 is on top.  The poster wants it to look like the green plot is on top.

 

If you take your graph and make the plot lines thicker, it will be more obvious to you.

 

Active Plot property node does not have change the order of the plots in anyway.  It just determines which plot is "active" so that any property nodes that affect that one plot such as changing point styles or colors will act on a specific plot.

Message 7 of 19
(6,240 Views)

To clarify:

  • Plot order can be changed by manipulating the order of the array of plots (Plot names and line colors could also be manipulatead such that "MyPlotX" could always be "MyPlotX" and represented as a Blue line.)  Since the Z Order of Plots in a graph is dependant on element order in the array of plots "MyPlotX" could be manipulated to any layer of the graph's Plot Area.   Doing this changes the order of plots in the Plot Legend.  The OP hoped to avoid this behavior as it could confuse users. {EDIT}? Or, so I assumed.
  • The Z Order of Plots in a graph is dependant on element order in the array of plots.  Changing this limitation requires modification to how Graphs and Charts draw plots.  The draw routines are not easilly exposed and this change is likely to require the intervention of NI R&D to implement safely.

The Idea Exchange would be a good place to vet opinions from the LabVIEW community about the importance of adopting this additional funcionality.


"Should be" isn't "Is" -Jay
Message 8 of 19
(6,228 Views)

Thank you Cameron, Gerd, and RavensFan.  I am the original poster. Cameron, I will try your VI soon and see if it lets me change what some are calling the "Z order" of the plots, i.e. which lines get drawn on top of which. RavensFan is right that I do not want to have the plots change color and syle as I re-order them.  I just want to "move the green line to the forefront" as RavensFan suggests.  An attached screenshot shows what I don't want: plots 3 and 4 hiding behind plots 1 and 2.

0 Kudos
Message 9 of 19
(6,227 Views)

I see that, RF and Jeff. I only did the first part of my first example in the one in my last post ("swap data set position") because it was lunchtime and I was hungry. My point was that you can change the order in which the plots are drawn from indexing a 2D array as well as from swapping two 1D arrays (or two whole graphs). Yes, the white graph is always drawn first, but if you look at the "increasing line" plot (which I called plot 1 in the enum), you will see that it is in front, middle, or back, depending on the order desired.

 

 

If you want to keep the data sets in consistant colors, as well as change the order they were drawn in, then all you have do is change the Active Plot colors as well.

 

If you want a static legend, then just put up a decoration (you can cut and paste from one of these dynamic ones, then leave them out).

 

Is this what you were thinking of?  How about you, OP?

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 10 of 19
(6,220 Views)