LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Managing several separate graphs with the same x-axis

Hello, I have a measurement that measures several (9 to be exact) parameters over time (all in fixed intervals). I would like to plot each of the parameters in its own graph. Therefore the x-axes of these graphs are all the same. I don't want all parameters in one graph since 9 plots will be very messy.

 

Now of course I can plot each in its separate xy-graph align them in a 3x3 grid and call it a day. But if the y-value of one graph changes to, for example. 200000 and the other stays at 2, then the y-axis will misalign. In addition it is a chore to manually manage 9 separate graphs.

 

Is there a way in LabVIEW to automatically handle multiple graphs, all with the same x-axis? It would save me a lot of manual setup, alignment and mundane coding.

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

Is every parameter the same kind of measurement, like all temperatures or all voltages?

 

My first thought would be a tab container, one tab page for each graph, and build an array of references to each graph and operate on them that way.

 

Also, how do you want the user to be able to interact with the graphs (zooming, changing axis ranges, etc)?

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 2 of 7
(4,272 Views)

No, there is no built-in way to keep all of the graphs synced up. You will need to code that yourself, but I don't think it'll be too bad.

 

First make a list of what exactly you want to keep constant between the plots. You mentioned Y axis min and max values already. I would assume you'd want X as well. Do the plot colors need to match? Fill values? Line densities? Make a list.

 

AFAIK there's no event that happens on an axis autoscale event, so you'll need to detect it. If it were me, I think I'd set the graphs to NOT autoscale by themselves, then write an "update" function that had references to each graph. In that VI, I would:

 

1- Defer panel updates

2- Loop through the array of plot references

     a- Set Autoscale Y axis to True

     b- Get new Y axis min and max

3- Get min value for Y axis Min and max value for Y axis Max

4- Loop through the array again

     a- Set Autoscale to False

     b- Set new Ymin/max values

5- Undefer panel updates

 

I'm not sure the autoscale would happen if Defer Panel Updates is False, but it's what I'd try first. You can run this VI after each time you write data to the plot. With Defer Panel Updates True, you won't get flickers doing all of the autoscaling and manipulation, and it'll be pretty snappy. If you're writing data to the plot very frequently you could call this VI less frequently; for a UI I think 10 Hz would be plenty.

 

Redhawk92 has some good points though. What if a user wants to zoom in on one plot? Do you zoom all of them? If so, what happens when you're zoomed in and a new point shows up? Do you want it autoscaling? You will need to maintain a separate "Autoscale all plots" variable if you want to temporarily disable the all-plot-sync feature.

 

I'd also recommend reevaluating whether or not you just want one single plot. You can do a lot with multiple Y axis scales, and if you use something like https://colorbrewer2.org to pick your plot colors (instead of the not great default colors) you can get visually distinct plots that are simpler to read. Of course without knowing your application your current solution might be the best, just a thought.

0 Kudos
Message 3 of 7
(4,252 Views)

@Basjong53 wrote:

Hello, I have a measurement that measures several (9 to be exact) parameters over time (all in fixed intervals).


I think most misunderstood your question. You seem to be talking about unwanted resizing of the plot area so the marker labels fit.

 

altenbach_0-1593451406233.png

 

 

If the intervals are fixed, you should use waveform graphs, not xy graphs. To prevent resizing of the plot area, you need to right-click and uncheck "autoadjust scales". Make sure you resize the plot area so all axis marker labels fit. You should also use e.g. a scientific format for the ticks so their width remains similar (e.g. 2E0 vs 2E5).

 

altenbach_0-1593451578493.png

 

Message 4 of 7
(4,244 Views)

@FireFist-Redhawk  ha scritto:

Is every parameter the same kind of measurement, like all temperatures or all voltages?

 

My first thought would be a tab container, one tab page for each graph, and build an array of references to each graph and operate on them that way.

 

Also, how do you want the user to be able to interact with the graphs (zooming, changing axis ranges, etc)?


The parameters are different, some resistance, voltage, current etc.. so wildly different orders of magnitude.

 

An array of reference is a good idea. But everytime a user does something with the graph (like zooming in like you said) it'll have to be programmed.

 

I was wondering if there was an internal way to have synchonized graphs. But I suppose not.

 

@BertMcMahan thanks for the suggestion about the x-axis scaling. I'll do that then.

 

@altenbach I'm aware of that function, my problem is that I have to manually resize the graphs and kind of eyeball the positions. It's kind of doable for 9 graphs (still boring) but with more graphs it becomes impossible, hence my question if there was an automate way to sync graphs.

0 Kudos
Message 5 of 7
(4,168 Views)

@Basjong53 wrote:
@altenbach I'm aware of that function, my problem is that I have to manually resize the graphs and kind of eyeball the positions. It's kind of doable for 9 graphs (still boring) but with more graphs it becomes impossible, hence my question if there was an automate way to sync graphs.

No need to "eyeball", the size in pixels is shown in a small popup below the window while resizing.

 

altenbach_0-1593706886326.png

 

 

I typically make one graph, disable the autoadjust property, resize plot area as desired,  then drag-shift to make copies for all others.

 

You can also always iterate over all size properties, find the smallest, and adjust all others to it. How often do the ranges change?

0 Kudos
Message 6 of 7
(4,162 Views)

@altenbach  ha scritto:

@Basjong53 wrote:
@altenbach I'm aware of that function, my problem is that I have to manually resize the graphs and kind of eyeball the positions. It's kind of doable for 9 graphs (still boring) but with more graphs it becomes impossible, hence my question if there was an automate way to sync graphs.

No need to "eyeball", the size in pixels is shown in a small popup below the window while resizing.

 

altenbach_0-1593706886326.png

 

 

I typically make one graph, disable the autoadjust property, resize plot area as desired,  then drag-shift to make copies for all others.

 

You can also always iterate over all size properties, find the smallest, and adjust all others to it. How often do the ranges change?


You're right, I'll do your method and make some functions to adjust all graphs.

 

Thanks for the help everyone

0 Kudos
Message 7 of 7
(4,159 Views)