5

I have created this surface plot in Matlab and use the wonderful program Matlab2tikz to export it to LaTeX. It generates me a .tikz file and when I try to use it I get an error.

I have found out! that there are some lines in the code: title={$\text{v}_\text{0}\text{ sensitivity}$}, and \addlegendentry{$\text{v}_\text{0}\text{=0}$}; three times (there are three surfaces, I assume that is why).

If I comment these out it works. Does anyone know what is up? I can supply the code and a minimal example, but I thought this would be even more helpful in this case.

Btw. I know nothing about tikz except how to get them out of Matlab and into LaTeX, I know just a little about LaTeX.

Edit: The error I get is:

! Paragraph ended before \pgfplots@glob@TMPd was complete.

and it seems to be only sensitive to including the addlegendentry lines. Including amsmath does not remove the error.

Edit2: If this is not allowed, please let me know. The problematic file can be downloaded here. There is no copyright, it is made by me and is by no means secret or dangerous. The file contains three large sets of numbers and the problematic lines comes right after.

Edit3: This is how the picture, optimally, should look though with added legends. It has taken literally hours to get the colours right in Matlab, so it would be quite a defeat to not get them right in LaTeX.

  • It always helps to say exactly what the error is, but if it is undefined command \text then you need amsmath (or amstext) package – David Carlisle Oct 10 '14 at 17:41
  • @DavidCarlisle It helped with the first one indeed. Thanks for the tip, I have included it and will continue to do so going forward :) – Henrik Oct 10 '14 at 17:55
3

You have some comflicting colormap options. After fixing them and adding col sep=tab it works properly. So something must be in your preamble causing the problem.

\documentclass{standalone}
\usepackage{pgfplots,mathtools}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{colormaps}
\begin{document}
\begin{tikzpicture}

\begin{axis}[%
%width=\figurewidth,
%height=\figureheight,
view={-240.5}{8},
scale only axis,
xmin=0,
xmax=0.4,
xlabel={Strike},
xmajorgrids,
ymin=0,
ymax=3,
ylabel={Time to Maturity},
ymajorgrids,
zmin=0,
zmax=3.5,
zlabel={Implied Volatility},
zmajorgrids,
title={$\text{v}_\text{0}\text{ sensitivity}$},
axis x line*=bottom,
axis y line*=left,
axis z line*=left,
legend style={at={(1.03,1)},anchor=north west,draw=black,fill=white,legend cell align=left}
]

\addplot3[%
surf,
opacity=0.7,
shader=faceted,
draw=black,
mesh/color input=colormap,
mesh/rows=30]
table[row sep=crcr,header=false,meta index=3] {0.0225   0.0849315068493151  
%
% loads of data here
%
};
\addlegendentry{$\text{v}_\text{0}\text{=0}$};

\addplot3[%
surf,
opacity=0.7,
shader=faceted,
draw=black,
mesh/color input=colormap,
mesh/rows=30]
table[row sep=crcr,header=false,meta index=3] {
%
% loads of data here
%
};
\addlegendentry{$\text{v}_0=0.048435$};


\addplot3[%
surf,
opacity=0.7,
shader=faceted,
draw=black,
colormap={mymap}{[1pt] rgb(0pt)=(0,0,1); rgb(63pt)=(0,1,0.5)},
mesh/rows=30]
table[row sep=crcr,header=false,col sep=tab] {
%
% loads of data here
%
};
\addlegendentry{$\text{v}_0=0.2$};

\end{axis}
\end{tikzpicture}%


\end{document}

enter image description here

  • Hi Percusse! I appreciate your help a lot. I will look into it myself, but maybe you know. The colours are a bit off now (you can see the true ones in my edit), do you know if I am able to get them right as well? Thanks you. – Henrik Oct 11 '14 at 6:42
  • I do not understand it properly, but I think that the explicit statement means that the colour is contained in the data. It seems that there are more numbers than in the last case - I do now know why that is not compatible with legends. – Henrik Oct 11 '14 at 8:19
  • @Henrik Ah, sorry, I'm colorblind so I can't see muh of the difference – percusse Oct 12 '14 at 15:06
  • No problem! You helped me to realise that a part of the problem was that my tex was outdated - the rest was solved in my other question. – Henrik Oct 12 '14 at 16:29
4

To define \text as this code intends then you need amsmath (or amstext) package

  • Hi David. Thanks for your answer it lets me compile the first troublesome line. It still gives the error:! "Paragraph ended before \pgfplots@glob@TMPd was complete." when I try including the last three. – Henrik Oct 10 '14 at 18:11
  • @Henrik ah I didn't see the edit, that probably means you have a blank line (paragraph break) in a wrong place, without a proper test file impossible to say more – David Carlisle Oct 10 '14 at 18:25
  • No problem. I have uploaded the file if that is any help. – Henrik Oct 10 '14 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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