I am trying to plot large amounts of points using some library. The points are ordered by time and their values can be considered unpredictable.
My problem at the moment is that the sheer number of points makes the library take too long to render. Many of the points are redundant (that is – they are “on” the same line as defined by a function y = ax + b). Is there a way to detect and remove redundant points in order to speed rendering ?
Thank you for your time.
The following is a variation on the Ramer-Douglas-Peucker algorithm for 1.5d graphs:
In python this could be
The output is
[(0, 0), (30, 30), (50, 0)].About python syntax for arrays that may be non obvious:
x[a:b]is the part of array from indexaup to indexb(excluded)x[n:]is the array made using elements ofxfrom indexnto the endx[:n]is the array made using firstnelements ofxa+bwhenaandbare arrays means concatenationx[-1]is the last element of an arrayAn example of the results of running this implementation on a graph with 100,000 points with increasing values of
epscan be seen here.