The following problem is one that may have showed up to you while plotting a large data collection. Suppose you have a data set of say 1 million points. ListLinePlot
will use all of those points to create your plot. Unfortunately, if the points are so close together they will overlap in the plot and they become irrelevant.
I was wondering if there is some quick way in Mathematica to get rid of the redundancies in the plots. The term redundancies depends of course of the image resolution (size).
Let us work with the following example
rx[n_] := Accumulate[Prepend[RandomVariate[ExponentialDistribution[1000], n], 0]]
ry[n_] := Accumulate[Prepend[RandomVariate[NormalDistribution[0, .001], n], 0]]
x = rx[100000];
y = ry[100000];
ListLinePlot[Table[{x[[i]], y[[i]]}, {i, Length[x]} ]]
Here is one of the many possible plots generated by the above
This plot was generated with 100,000 points and some of them may not even be visible since other points overlap part of the point. The question is, is there some built in function that gives us a way to remove the redundancies and thus reducing the size of the figure?
I should be more precise. If this plot is to be exported as a raster plot (jpeg, png) then there is no problem. The problem arises if we export it as a pdf or eps. The resulting vector format will have to plot all of those points and it will take a while to display it when in reality we only have a few points to display.
The very naive way I did before was to remove some points from my initial data, as follows:
ListLinePlot[Table[{x[[i]], y[[i]]}, {i, 1, Length[x], 100}]]
And you can imagine what will happen if I skip 1000 points at a time
ListLinePlot[Table[{x[[i]], y[[i]]}, {i, 1, Length[x], 1000}]]
Possible Solution 1
The first idea that came to my mind was to loop over my data and see if the points are close to each other, if they are sufficiently close (we can use a parameter to decide this) then we remove one of them.
This solution will remove points from our initial data set but we want to make it so that we do not remove important features of the plot as I did with the 3rd plot.
Possible Solution 2
The other solution was to export/rasterize the final figure I wanted (only the lines in the plot, this excludes the axes or any other objects). Once this is done then we outline the plot and make a vector figure of it again.
Keep in mind that we are trying to reduce the size of points that are being plotted while making the plot resemble what Mathematica plotted very naively.
Any ideas of how to implement any of the ideas above or an even better one to achieve the desired result?