Graphics, Figures & TablesTrouble with figure - TeX capacity exceeded

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Trouble with figure - TeX capacity exceeded

Post by Bozack »

I'm using a script to export figures from MatLab to PSTricks code, and want to have a figure with a huge amount of data in a report. My problem is that LaTeX doesn't seem to be able to handle the large number of points the code defines.

I wanted to attach a minimal (should-be) working-example, but it told me it was not allowed to be above 256 KiB (the file is 935 KiB, and if I package it the best I can, it is still 260 KiB), so you can get the file here instead: http://bozack.dk/div/trialexportfigure2.tex

When I try to compile it (with MikTeX), I simply get the error TeX capacity exceeded, sorry [main memory size=1500000].

It's no wonder that the error happens, but what do I do to actually make the figure without it stalling with this error? Or is there simply not a way to get it to include so many points?
Last edited by Bozack on Tue May 04, 2010 9:27 am, edited 2 times in total.
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: Trouble with figure - TeX capacity exceeded

Post by php1ic »

Can't offer any personal advice, but this thread may help as it looks to be very similar

http://www.latex-community.org/forum/vi ... =45&t=8195
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Re: Trouble with figure - TeX capacity exceeded

Post by Bozack »

The only trouble is that the forum thread you linked to was about Tikz, which I know nothing about. It googled it a bit, and as far as I understand, it is a "language" like PSTricks, to make graphics inside LaTeX documents? The examples I found were not immediately obvious for me to understand, and I would really really like to keep using PSTricks for this, instead of having to learn yet another language.. :(

So I'm not really able to use the advice with using a CVS file for the data-points and such, that were given in the linked thread..

Doesn't anyone else have any ideas? :cry:
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Trouble with figure - TeX capacity exceeded

Post by localghost »

Bozack wrote:The only trouble is that the forum thread you linked to was about Tikz, which I know nothing about. It googled it a bit, and as far as I understand, it is a "language" like PSTricks, to make graphics inside LaTeX documents? The examples I found were not immediately obvious for me to understand, and I would really really like to keep using PSTricks for this, instead of having to learn yet another language. [...]
No matter which package is in use, the principal stays the same. It is much faster, less memory consuming and a little bit more comfortable to plot a CSV (Comma Separated Value) file. And Matlab should offer to export the data as such a CSV file. But perhaps you already have the data present in an external file. If so, you can upload it here as attachment(!) to your next post.
Bozack wrote:[...] So I'm not really able to use the advice with using a CVS file for the data-points and such, that were given in the linked thread. [...]
If you can't manage that on your own, ask somebody from your personal surroundings who is familiar with that. Otherwise I'm pessimistic about specific help. And it's very unlikely that someone extracts the data from the file you linked. As soon as the data file is present, the final result is only some steps away.
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Trouble with figure - TeX capacity exceeded

Post by Bozack »

I wasn't aware that it was possible to plot CVS values from a file with PSTricks - I've tried searching for it, but couldn't find anything.

The data defined in \mydata in the tex file I linked to earlier are all contained in the cvs file in the attached zip file below.

I guess all I need is a command to replace the

Code: Select all

\dataplot[plotstyle=line,showpoints=true,dotstyle=*,dotsize=\MarkerSize,linestyle=none,linewidth=\LineWidth,linecolor=color617.0006]{\mydata}
code in the tex file, to plot the data in the cvs file instead? :)
Attachments
export.zip
(135.31 KiB) Downloaded 242 times
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Trouble with figure - TeX capacity exceeded

Post by localghost »

Bozack wrote:I wasn't aware that it was possible to plot CVS values from a file with PSTricks - I've tried searching for it, but couldn't find anything. [...]
Of course you can. That's what the pst-plot package is made for.
Bozack wrote:[...] The data defined in \mydata in the tex file I linked to earlier are all contained in the cvs file in the attached zip file below. [...]
No, the attached file contains other data. The range of y-values differs from the data you introduced first. I deleted the whole data and the actual plot from your first example and got a grid with x in (0,600) and y in (-5,30). But apart from that I took the data file you attached to your last post and built an example for a nice plot as shown below.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage{pst-plot,pstricks-add}

\begin{document}
	\begin{figure}[!ht]
		\centering
		\scriptsize
		\psset{llx=-1cm,lly=-1cm,urx=0mm,ury=0mm}
		\psset{xAxisLabel={x axis},xAxisLabelPos={300,-0.5}}
		\psset{yAxisLabel={y axis},yAxisLabelPos={-45,2}}
		\psset{plotstyle=line}
		\readdata[nStep=10]{\data}{export.txt}
%		\psframebox[linestyle=dashed,linewidth=0.4pt]{%
		\begin{psgraph}[Dx=100,Dy=1,subticks=5,ticksize=0pt 4pt](0,0)(600,4){9.9cm}{7cm}
			\psaxes[Dx=100,Dy=1,subticks=5,labels=none,ticksize=-4pt 0](600,4)(0,0)(600,4)
			\listplot[linecolor=blue]{\data}
		\end{psgraph}
%		}
		\caption{A Matlab data plot with \textsf{PSTricks}}\label{fig:matlab-pstricks}
	\end{figure}
\end{document}
The final output is attached. As you can see the code is much smaller than the export result (regardless of the data). Note that only every 10th value of the data file (more than 50000 lines!) is read. This is necessary to prevent an overflow. The only thing left to do is inserting the right axis labels. Details can be found in the according manuals.
Attachments
matlab-pstricks-plot.pdf
A Matlab data plot with PSTricks
(13.82 KiB) Downloaded 268 times
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Re: Trouble with figure - TeX capacity exceeded

Post by Bozack »

First of all, thank you for replying so specifically and for being so patient with me :)

Sorry about the cvs file not containing the same data - I have several versions of the data I want plotted, and I wasn't sure which graph I actually gave in the beginning (and since I couldn't get it plotted, I didn't really think I had a way to figure it out). The principle was the same, and I also wanted these data plotted in the same way anyway.. I guess the data in the old file was actually the data times 20, and with some of the data points removed.

Thank you for showing me how to use pst-plot to read data - I actually read through a big part of the manual, but didn't understand the readdata command well enough :( It helps a lot with an example relevant to my case :)

But, the whole point in making this thread was to be able to plot all my data points without getting an overflow. This was also easily done via the "matlab to PSTricks" script I used ealier (binning 10 points together at a time, and using their average instead - and simply plotting these points rather than the data). The code you gave me only read every ten points in the file, and plots these (as you also said), so that really wasn't the point :(

Is there really no way to be able to plot all the points in the file without getting an overflow of some kind? Something like only reading in parts of the file at a time or the like?
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Trouble with figure - TeX capacity exceeded

Post by localghost »

Bozack wrote:[...] Is there really no way to be able to plot all the points in the file without getting an overflow of some kind? Something like only reading in parts of the file at a time or the like?
After all, there is. I did the compilation on my more powerful notebook. At first, I slightly changed the code as shown below.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage{pst-plot,pstricks-add}

\begin{document}
   \begin{figure}[!ht]
      \centering
      \scriptsize
      \psset{llx=-1cm,lly=-1cm,urx=0mm,ury=0mm}
      \psset{xAxisLabel={x axis},xAxisLabelPos={300,-0.5}}
      \psset{yAxisLabel={y axis},yAxisLabelPos={-45,2}}
      \psset{plotstyle=line}
%      \psframebox[linestyle=dashed,linewidth=0.4pt]{%
      \begin{psgraph}[Dx=100,Dy=1,subticks=5,ticksize=0pt 4pt](0,0)(600,4){9.9cm}{7cm}
         \psaxes[Dx=100,Dy=1,subticks=5,labels=none,ticksize=-4pt 0](600,4)(0,0)(600,4)
         \fileplot[linecolor=blue]{export.txt}
      \end{psgraph}
%      }
      \caption{A Matlab data plot with \textsf{PSTricks}}\label{fig:matlab-pstricks}
   \end{figure}
\end{document}
This plots directly from the file. The compilation went smoothly and it took only five(!) minutes. On my slower desktop machine I interrupted the compilation process due to lack of patience. I attached the final result. Note the difference in size to the first plot.
Attachments
matlab-pstricks-plot.pdf
The same plot but now with the full data.
(173.6 KiB) Downloaded 375 times
User avatar
Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Trouble with figure - TeX capacity exceeded

Post by Bozack »

Thank you very very much! The fileplot command was just what I needed! :D
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
Post Reply