Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a plot with a lot of measurement datapoints. I exported this plot from Matlab2tikz.

When I wanted to compile this, it said that the memory was exceeded. Now I found this, How to expand TeX's “main memory size”? (pgfplots memory overload). It tells me that I can export different tikzpictures to different files. This unluckely didn't help me since I only got 1 tikzpicture and it is already causing the problem.

So I actually tried to increase the memory of TeX. I went to /usr/share/texlive/texmf/web2c then in texmf.cnf I changed main_memory = 3000000 to main_memory = 5000000. Then I ran texhash and tried to compile my TeX file again.

My problem is that after I increased the memory limit I again get the same error. ! TeX capacity exceeded, sorry [main memory size=3000000].. However I did just changed it to 5000000. So I presume that I did something wrong when increasing the memory limit?

-edit-

Eventually I just used lualatex. This is due to the fact that I think there is something wrong with my texlive install, it is installed twice on my system for some reason. I think however that the answer of @Heiko Oberdiek is correct hence mark his question as the correct one.

share|improve this question
    
Have you considered to export the image generated with Matlab and create the plot with the command \addplot graphic? –  Iovem Oct 5 '12 at 10:05
    
No because I create different plots in Matlab. They are autogenerated by a tool I use. I then export them to tikz and in tikz combine all the plots. –  WG- Oct 5 '12 at 10:12
3  
You could try compiling the document with lualatex, which doesn't have those memory limitations. –  Jake Oct 5 '12 at 10:50
add comment

2 Answers 2

up vote 14 down vote accepted

From texmf.cnf:

% Memory. Must be less than 8,000,000 total.
%
% main_memory is relevant only to initex, extra_mem_* only to non-ini.
% Thus, have to redump the .fmt file after changing main_memory; to add
% to existing fmt files, increase extra_mem_*.  (To get an idea of how
% much, try \tracingstats=2 in your TeX source file;
% web2c/tests/memtest.tex might also be interesting.)

Thus you have to regenerate the format files (fmtutil) to see an effect of changing main_memory.

share|improve this answer
    
I ran fmutil in sudo fmtutil-sys --all in /usr/share/texlive/texmf/web2c but I still get ! TeX capacity exceeded, sorry [main memory size=3000000]. instead of ! TeX capacity exceeded, sorry [main memory size=5000000], what I would expect. –  WG- Oct 5 '12 at 10:27
    
@Wouter Find the relevant texmf.cnf by running kpsewhich texmf.cnf as normal user. Edit this one (as root if located under /usr/share/texlive/). –  AlexG Oct 5 '12 at 10:58
    
@AlexG, just did that. Still does not work :-( I believe for some reason I also have 2 texlive installations... When I ran kpsewhich texmf.cnf I was directed to: /usr/local/texlive/2012/texmf.cnf Also I have 2 texmf.cnf's I just noticed. One is located in: /usr/local/texlive/2012/texmf/web2c and one in /usr/share/texlive/texmf/web2c –  WG- Oct 5 '12 at 11:06
1  
@Wouter: Dont't touch the config files below .../web2c/.... Edit the one kpsewhich texmf.cnf told you. As root, enter kpsewhich texmf.cnf once more, in order to see which installation will be affected by subsequent fmtutil-sys --all. It is probably the one under /usr/share which was installed via your Linux distribution's package manager. I recommend installing TeXLive-2012 as a normal user into your home directory, e. g. to ~/bin/texlive/2012 and prepend ~/bin/texlive/2012/bin/i386-linux to your PATH environment variable. –  AlexG Oct 5 '12 at 12:12
add comment

Increasing the memory may help you to compile your plots but you will end up with very big files that takes lots of time to load by pdf viewers and make scrolling jerky. In addition, as you increase your plots complexity you might hit a performance cap.

Here is another solution that gives very small files while keeping the 'crispiness' of the full tikz approach.

  1. Plot each elements that are of differing colour on different graphics. Ensure that the axes limits are the same, remove the axis (axis off in matlab) and export them as high resolution png using the print command

    print -dpng -r800 *name_of_file.png*
    
  2. Convert the .png to bitmap with either gimp or imagemagick. With the latter :

    convert *name_of_file.png* *name_of_file.bmp*
    

You might want to directly export in bmp format from Matlab. I have not tested it though and have no license at hand right now.

  1. Use potrace to retrieve an .svg vector trace of your .bmp

    potrace *name_of_file.bmp* -s
    
  2. Then recombine the .svg with Inkscape, applying wanted colours that have been lost when using potrace.

  3. Either export your final result as pdf or as tikz code using Inkscape inkscape2tikz extension. If the former, use \addplot graphic (see pgfplots manual about that command).

I've use that technique on scatter plots with 10 000 points that overlap quite a lot. The resulting files are very small but almost perfectly slick while .png look edgy when one fancy to zoom a lot.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.