Reducing a graph's datapoints while maintaining its main features

Viewed 278

I have a large set of data, which needs to be displayed on a graph repeatedly.

The graph has a width of 1400 pixels. The data contains more than 30,000 datapoints. Thus, I would like to reduce the datapoints to a number roughly around 1400, while still maintaining the main features of the graph (max, min, etc.).

If you look at programs like LabVIEW and MATLAB they are able to display graphs containing a large number of datapoints, by compressing the data, without losing the graph‘s main features. I am unable to use a simple decimation, average or moving average, as this would not maintain the features of the graph.

Does anyone know of any algorithms which are being used by these kind of programs or would give me the expected results? I am also interested in performance algorithms.

2 Answers

LabVIEW makes use of a max-min decimation algorithm.

As you can see from the reference a run of data points is compressed into a maximum and minimum value and then both points are plotted at the same x-axis value with the vertical pixels between the two points filled.

If you don't have control over how each pixel of the plot is rendered then you can try implementing something similar where you take say eight points, find the maximum and minimum values and then pass those to the plotting function/tool (accounting for the order that they occur in the series) - giving you a decimation factor of four.

I've already used the Ramer–Douglas–Peucker algorithm in LabVIEW for a project that had several graphs updated continuously, it worked fine!

This algorithm doesn't have a target number of points as output, but you tune the hyperparameters to meet your desired output size.

I don't have my implementation to share with you, but the algorithm is very simple and can be easily implemented in LabVIEW or another language. In LabVIEW you can put it inside the definition of a xControl to abstract it from your code and use it multiple times.

Related