Yet another Tex Capacity exceeded error.
I am generating a matlab scatter plot which without modification resulted in a 64.5 MB printed eps file. Using that plot directly in matlab2tikz resulted in a large tikz file (34.5 MB) which gives me the Tex capacity error.
I already researched and found a number of possible solutions:
Externalize tikz figures.
- Described in externalize-tikz This ensures that every tikz figure has it's own tex job. I applied this one but it still gives me the capacity error
- Lualatex in stead of pdflatex which does not have a tex capacity error due to dynamical memmory allocation.
- Increase texs main memory as in Increasing TeX's main memory
The last two solutions are in my opinion not the best since it result in large pdfs. The graph that want to plot should not require that amount of memmory. Also luatex does not work with my university provided tex style.
Decrease tikz size in matlab
- dsplot dsplot did not work with standard color, linewidth and other graphical controls.
reduce_plot reduce_plot wrapper around LinePlotReducer -> Manages the information in a standard MATLAB plot so that only the necessary number of data points are shown. For instance, if the width of the axis in the plot is only 500 pixels, there's no reason to have more than 1000 data points along the width. This tool selects which data points to show so that, for each pixel, all of the data mapping to that pixel is crushed down to just two points, a minimum and a maximum. Since all of the data is between the minimum and maximum, the user will not see any difference in the reduced plot compared to the full plot.
cleanfigure('minimumPointsDistance', X) cleanfigure removes the unnecessary objects from your MATLAB plot
Of the last three methods, I used clean_figure and by playing with its value X I can drastically reduce the size of the exported tikz file. However even with a tikz file size of 500kB the tex capacity error shows up. If I use an extremely large minimumPointsDistance and reduce the figure to 30kB it gives no error but then my figure is quite different as well.
Also reduceplot worked well and it reduced the tikz file to 700 kB. But again the tex capacity error.
My question therefore is, how can I avoid this capacity error while still ensuring a decent quality figure. And shouldn't a 500kb or 700kb tikz file be externally compilable or are these sizes still large?
Also I wonder what the memory size=5000000 exactly means. Is that 5M bytes? does that mean that I should be able to compile a 5M bytes = 4.76 Mb tikz file?
.epsfile in your TeX document, after usingreduce_plotorclean_figure. You can then draw axes and labels on top of the included graphics file. – Nick Matteo Jan 15 '15 at 22:08