4

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?

Max Baeten
  • 43
  • 3

2 Answers2

2

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:

Plot (Big):

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.

DSPLOT:

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

matlab2tikz:

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.)

knedlsepp
  • 6,065
  • 3
  • 20
  • 41
1

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);

yoh.lej
  • 1,104
  • 6
  • 14
  • This could be useful for regular data, however my data is not really regular and therefore a fixed step will reduce my plot but also it might (slightly) change my data. – Max Baeten Jan 14 '15 at 14:10
  • I always try simple solutions before resorting to using the heavy artillery, but in your case it looks like you need the heavy artillery indeed :) – yoh.lej Jan 14 '15 at 14:30