Reputation: 43
I am Plotting and printing a large dataset to eps:
plot(Voltage,Torque,'b.')
print -depsc figure.eps
Through these million data points I will fit a graph. However since the sizes of the Voltage and Torque vectors are enormous my eps file is 64.5 MB.
Most of the plotted points however lie on top of other points or very close. How can I reduce the size of the .eps while still having limited effects on the way the data is shown in the graph? Can I make matlab detect and remove data points close enough to other already plotted points?
although it is a scatter plot, I am not using scatterplot since all points should have the same size and color. Is it possible to use scatterplot to remove visual obsolete datapoints?
Upvotes: 4
Views: 1963
Reputation: 6084
Beyond stackoverflow, the File Exchange is always a good place to start the search for a solution. In this case I found the following submissions:
This simple tool intercepts data going into a plot and reduces it to the smallest possible set that looks identical given the number of pixels available on the screen.
This version of "plot" will allow you to visualize data that has very large number of elements. Plotting large data set makes your graphics sluggish, but most times you don't need all of the information displayed in the plot.
If you end up using the plot in a LaTeX-file, you should consider using
This is matlab2tikz, a MATLAB(R) script for converting MATLAB figures into native TikZ/Pgfplots figures.
For use in LaTeX you don't have to go the detour of PostScript and it will make for beautiful plots.
It also provides a function called: CLEANFIGURE('minimumPointsDistance', DOUBLE,...)
, that will help you reduce the data points. (Possibly you could also combine this with the above solutions.)
Upvotes: 2
Reputation: 1104
If your vector Voltage
is already sorted and more or less regularly spaced, you can simply plot a fraction of the data:
plot(Voltage(1:step:end),Torque(1:step:end),'b.')
with step
set to find the right tradeoff between accuracy and size of your eps file.
If needed, first sort your vectors with:
[Voltage,I] = sort(Voltage);
Torque = Torque(I);
Upvotes: 1