From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hiding time periods on an XY Graph

I am historically trending production data over the working week between 7am – 3pm. If my graph displays the previous x number of days data (governed by numeric control), the plot is broken because the x-axis is on a continuous time scale which means it also shows weekday evenings and weekends. I would like to edit my code so the graph only shows shift times and excludes these ‘gaps’ in the data.

Does anyone know how to format the scale to show only the production shifts? I have attached my code to show how I’ve put this together.

Many thanks for the help

Stuart

0 Kudos
Message 1 of 12
(4,417 Views)

Hi Stuart,

I'm pretty sure that there is no way that you can configure a graph scale to be broken/non-continuous.

If you want to reduce or eliminate the gaps in your data, you will probably have to manipulate the "time" element of the data, before plotting.

Mark

0 Kudos
Message 2 of 12
(4,408 Views)
Hi Mark, thanks for getting back to me. The recording of my data takes place within the correct time frame (7am - 3pm), so if i exported data from the citadel DB into excel the associated timestamps in the cells would only show times within the production shift. This means the time element of my data is correct. It is purely the display of the graph that needs altered. I have two ideas that i would like your opnion on if possible(?). Firstly, if the data is broken like this, i could as an alternative plot a trendline (an average of all data displayed) for x number of days displayed. This would link each days data to the next and would vary on the length of history (number of previous days) selected by the user. The trouble is i don't know how to do reintroduce the average of the plot into the XY graph. Its a bit like adding the linear trendline in excel i suppose. I have attached a jpeg to help explain. Secondly, could i plot zeros while we were 'off shift' (3.01pm - 6.59am) and then select to hide all zero values? This is cheating and uses up needless memory but it may get round the problem? The only other alternative is to export to excel and manipulate which defeats the purpose of viewing it in LabVIEW. Any suggestions or experience you have with this is greatly appreciated. Many thanks for your continuing support Stuart
0 Kudos
Message 3 of 12
(4,403 Views)
Hi, Stuart:

Did you try "Remove data breaks" option in Options cluster input of Read Traces Block?

Aitortxo
Aitortxo.
Message 4 of 12
(4,392 Views)

Hi Stuart,

I don't believe there's anything you can do in a LabVIEW graph to "break up" an axis' scale (which is what I thought you were hoping to do).

As regards plotting: I've not seen a "hide all zeros" option myself, but you acheive the same effect by setting values in an array to NaN (not a number) - NaN values are not plotted i.e. are effectively hidden.
 
Similarly, you could just plot data points without joining the points (i.e. configure the plot for no interpolation).
 
Plotting a trendline should be very easy - as simple as a multiple plot graph, one plot being raw data another the trendline.
 
It is also possible to add a plot to an existing graph of plots by using property nodes to read a graph's data, then add the additional cluster/array (plot) and then write the data back to the graph - I could post an example if you need to do this.
 
Mark.
 
 
Message 5 of 12
(4,390 Views)
Thanks to both of you for helping out, i was unaware of the options available in the read traces vi. Mark, although i've managed to remove the breaks from the plot, I was hoping you would show me how i can feed my average (calculated from "Get Trace Statistics" vi) back into the XY graph itself. I am a bit unsure how to include it in the existing cluster/array and convert the data type correctly. You could use my attached vi above as a demo if you like. Many thanks for helping me to understand this a little better. cheers Stuart
0 Kudos
Message 6 of 12
(4,373 Views)

Stuart,

If you want to plot a running average simultaneously with your existing graph plotting, then you must calculate the running average within the same loop then take the existing plot data and the average plot data (with x-axis values), wrap each plot data aray as a cluster, then build the two clusters into an array of clusters (effectively an array of plots) and pass to the graph terminal.

If you must plot the trendline/average after the main data has been plotted (outside the loop) then you could use code similar to the VI I've attached. Keep in mind that the data type for my graph's plots is "array of plots" where each plot is a "clustered array of clusters of [x,y] coordinate points" which is slightly different to yours.

Hope there's something useful in there somewhere.

Mark. 

Message 7 of 12
(4,363 Views)

>Thanks to both of you for helping out, i was unaware of the options available in the read traces vi. Mark, although i've managed to remove the breaks from the plot, 

 

I'm wondering how to do that; that is to say, have the plot not show the span of weekends in the x-axis when the X-axis data exists for weekdays only.

0 Kudos
Message 8 of 12
(2,755 Views)

This is something which by definition can't be done automatically*. You give the XY graph an array of arbitrary X values and now you want the graph to somehow decide which arbitrary gaps should be compressed and which shouldn't. It wouldn't have any way of knowing how to do that without some guidance, so Mark's reply is still true after 15 years - you need to compress the time element yourself to remove the gaps, while keeping track of what goes where.

 

Once you do that, you will also need to hide the X scale and redraw it on your own, as now the values in the data no longer correspond directly to the values in the scale. You can use a picture control and the graph's Map XY to Coords method to decide where to place your text for each marker. You will also need to account for updates/scrolling/resizing/zooming, etc. You can also use the graph's plot picture properties to embed the picture in the graph, but that would require you to manage the Y scale as well.

 

 

* Yeah, you could say "my values have relatively fixed gaps when they exist, just use that to figure out the missing sections", which may or may not be your situation, but that's not a guarantee for every data set.

 

 

 

Side note - there is a Marker Values[] property for the scale, but as far as I know, it just controls which values are shown in the scale, and the gaps between the scale markers are still determined by the mapping (linear or logarithmic). I don't know of a way to set an arbitrary gap in the graph grid/scale.


___________________
Try to take over the world!
Message 9 of 12
(2,739 Views)

Thanks for your comment.

>Mark's reply is still true after 15 years - you need to compress the time element yourself to remove the gaps, while keeping track of what goes where.

 

I guess I don't understand what he did based on this thread.

 

I made progress another way by using dual X axis feature, where you put sequential numerical days for data that exist in the bottom X axis and timestamp in the second (upper X axis). I'll come back and post a code snippet in ~24 h.  It looks promising, but there is still some adjustments to make to get it right. Advice of different sorts will be needed I expect.

 

>Side note - there is a Marker Values[] property for the scale,

Could be that this will come in useful.

0 Kudos
Message 10 of 12
(2,727 Views)