I have a MATLAB generated plot that looks as follows:

MATLAB generated plot

Generated with this code:

axis([1 511 0.5 1]);
ylabel('Normalized RMS error'); xlabel('q (um^-1)');

I then export it as a tikz using matlab2tikz(). And include it in my latex document:


The latex file will not compile due to Error: Dimension too large. <recently read> \pgf@yy l.537 \end{axis}.

Inside the .tikz document is as follows:

scale only axis,
xmin=1, xmax=511, xlabel={$\text{q (um}^\text{-}\text{1)}$},
ymin=0.5, ymax=1, ylabel={Normalized RMS error}]
\addplot [color=blue,solid,line width=1.0pt,forget plot]
table[row sep=crcr]{
1    -57.943745    \\
2    -14.11968    \\
3    -5.535387    \\
4    -2.4488078    \\
5    -1.0804409    \\
6    -0.30200709    \\
7    0.053585582    \\
8    0.32392563    \\
9    0.44304278    \\
511    0.90342708    \\

Note the data hangs around 0.8 or 0.9 most of the points.

I found if I change ymin from 0.5 to 0, it compiles fine. Help as to why it does not work in its current state is greatly appreciated. I need the y axis to only display 0.5 to 1 like it does in MATLAB.

Secondly, I have been playing around with aligning plots in a table, my current attempt is shown below. tikz plot example I am using largely this example: Insert image and list inside a table, but cant figure out two things:

  • How do I center the text under heading 'A'?

  • The vertical edges of the middle graph don't quite line up with the top, as shown by the red arrows in the image. Is this because the middle graph has brackets in one of the label titles that need to push it a bit to the right. How do I go about making them line up?

If possible I would like to do this by not having to alter my .tikz file once it has been created by matlab2tikz, but I understand if this is simply not possible.


  • A comment for anyone with the same first problem (Dimension too large). If you run the cleanfigure command that is provided in the matlab2tikz submission, then it will discard any points not actually visible in the plot. This got rid of the troublesome first points which were stuffing up my image, and it worked fine after. Mar 9, 2014 at 11:04
  • For what it's worth, I had a Dimension too large problem, and cleanfigure didn't fix it. I eventually realized I was setting an xtick that was way outside the axis limits, and that was causing the problem. Sep 18, 2015 at 22:44

1 Answer 1


The problem with "Dimension too large" is a weakness in pgfplots: it has to map all coordinates into TeX's limited number range eventually, and it fails to detect that it cannot do so without discarding coordinates.

In your case, the input range of the y coordinates is much greater than the actually displayed portion. I'd suggest to add restrict y to domain=-5:4 - this will discard any coordinates below -5 and above 4 (adopt as needed). I suppose this will assist pgfplots such that it can map all coordinates properly.

Regarding the alignment stuff: The general advice would be to

  • control the bounding boxes of your pictures. A good idea could be to use \begin{tikzpicture}[trim axis right]; this will exclude everything right of the right axis line from the bounding box. Then, configure your table such that the "B" column is right-aligned.
  • another alternative would be to configure both ylabel style and yticklabel style such that they have a minimum height; perhaps that has the same effect.
  • study section "Alignment Options" in the pgfplots manual carefully; it has lots of input on both horizontal and vertical alignment of multiple axes.

A more detailed answer would be possible if you post a minimal working example which demonstrates what you have so far.

Please note that you should, in general, pose only one question per post - it is considerably simpler to address issues separately rather than mixed.

I would suggest to pose a new question for the alignment stuff if needed; editing this will probably make it difficult to separate answers from the dimension too large issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .