matlab2tikz:将 jet 颜色图添加到 surfplot 时,tex 中出现一堆错误消息

matlab2tikz:将 jet 颜色图添加到 surfplot 时,tex 中出现一堆错误消息

我在 matlab 中创建了一个冲浪图,它也在图中正确描绘。

f3 = figure(3);
p3 = surf(X,Y,Z);
hold on;
p3.LineStyle = 'none';
colorbar; 
%change the color map
colormap(f3, jet(256));
%add axis labels
xlabel('X', 'Interpreter','latex'); 
ylabel('Y', 'Interpreter','latex'); 
zlabel('Z', 'Interpreter','latex'); 
matlab2tikz('filename.tex','width','\figW','height','\figH');

调用 matlab2tikz,屏幕上还会打印以下信息:

 *** Found colormap/jet to be a pretty good match for your color map (||diff||=0.00684254).
 *** Found colormap/jet to be a pretty good match for your color map (||diff||=0.00684254).

这是从 matlab2tikz 生成的 tex 文档:

\begin{tikzpicture}

\begin{axis}[%
width=0.806\figW,
height=\figH,
at={(0\figW,0\figH)},
scale only axis,
point meta min=-510718.977774975,
point meta max=-216253.369674834,
xmin=1.9,
xmax=2.3,
tick align=outside,
xlabel style={font=\color{white!15!black}},
xlabel={$I_C$},
ymin=0.8,
ymax=1.4,
ylabel style={font=\color{white!15!black}},
ylabel={$III_C$},
zmin=-510718.977774975,
zmax=-200000,
zlabel style={font=\color{white!15!black}},
zlabel={$\frac{\partial E}{\partial III_C}$},
view={-37.5}{30},
axis background/.style={fill=white},
axis x line*=bottom,
axis y line*=left,
axis z line*=left,
xmajorgrids,
ymajorgrids,
zmajorgrids,
colormap/jet,
colorbar
]

\addplot3[%
surf,
shader=flat, z buffer=sort, colormap/jet, mesh/rows=5]
table[row sep=crcr, point meta=\thisrow{c}] {%
%
x   y   z   c\\
1.9 0.8 -510718.977774975   -510718.977774975\\
1.9 0.9 -419619.039289088   -419619.039289088\\
1.9 1   -350000 -350000\\
1.9 1.1 -295437.343455786   -295437.343455786\\
1.9 1.2 -251783.826117989   -251783.826117989\\
1.9 1.3 -216253.369674834   -216253.369674834\\
2   0.8 -510718.977774975   -510718.977774975\\
2   0.9 -419619.039289088   -419619.039289088\\
2   1   -350000 -350000\\
2   1.1 -295437.343455786   -295437.343455786\\
2   1.2 -251783.826117989   -251783.826117989\\
2   1.3 -216253.369674834   -216253.369674834\\
2.1 0.8 -510718.977774975   -510718.977774975\\
2.1 0.9 -419619.039289088   -419619.039289088\\
2.1 1   -350000 -350000\\
2.1 1.1 -295437.343455786   -295437.343455786\\
2.1 1.2 -251783.826117989   -251783.826117989\\
2.1 1.3 -216253.369674834   -216253.369674834\\
2.2 0.8 -510718.977774975   -510718.977774975\\
2.2 0.9 -419619.039289088   -419619.039289088\\
2.2 1   -350000 -350000\\
2.2 1.1 -295437.343455786   -295437.343455786\\
2.2 1.2 -251783.826117989   -251783.826117989\\
2.2 1.3 -216253.369674834   -216253.369674834\\
2.3 0.8 -510718.977774975   -510718.977774975\\
2.3 0.9 -419619.039289088   -419619.039289088\\
2.3 1   -350000 -350000\\
2.3 1.1 -295437.343455786   -295437.343455786\\
2.3 1.2 -251783.826117989   -251783.826117989\\
2.3 1.3 -216253.369674834   -216253.369674834\\
};
\end{axis}
\end{tikzpicture}%

重现该错误的 MWE 如下:

\documentclass{article}  

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\newlength\figW 
\figW=4cm 
\newlength\figH 
\figH=4cm 

\begin{document}

\begin{figure}[ht]
\input{/PATH_TO_THE_TEX_FILE.tex}
\end{figure}

\end{document}

但是,编译 tex 文档时,会打印一堆错误消息:

(../pictures/energy_wrt_IIIC_analytical.tex
LaTeX Font Info:    Trying to load font information for TS1+lmr on input line 2
139.

(/usr/local/texlive/2022/texmf-dist/tex/latex/lm/ts1lmr.fd
File: ts1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
)
Missing character: There is no 4 in font nullfont!
Missing character: There is no . in font nullfont!
Missing character: There is no 4 in font nullfont!
Missing character: There is no 8 in font nullfont!
Missing character: There is no 7 in font nullfont!
Missing character: There is no 9 in font nullfont!
Missing character: There is no 2 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 5 in font nullfont!
Missing character: There is no . in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 4 in font nullfont!
Missing character: There is no 4 in font nullfont!
Missing character: There is no 4 in font nullfont!
Missing character: There is no 4 in font nullfont!
Missing character: There is no . in font nullfont!
Missing character: There is no 4 in font nullfont!
Missing character: There is no 8 in font nullfont!
Missing character: There is no 7 in font nullfont!
Missing character: There is no 9 in font nullfont!
Missing character: There is no 2 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no 0 in font nullfont!

! Package pgfplots Error: No such element: \pgfplotsarrayselect-1\of{pgfpl@cm@j
et@X}.

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.2139 \end{axis}
                 
This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.

! You can't use `the letter b' after \advance.
<argument> ...@rgb@X@left \advance \c@pgf@counta b
                                                  y1 \ifnum \c@pgf@counta <\...
l.2139 \end{axis}
                 
I'm forgetting what you said and not changing anything.

Missing character: There is no y in font nullfont!
Missing character: There is no 1 in font nullfont!
! Missing number, treated as zero.
<to be read again> 
                   <
l.2139 \end{axis}
                 
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing number, treated as zero.
<to be read again> 
                   \relax 
l.2139 \end{axis}
                 
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing number, treated as zero.
<to be read again> 
                   \pgfplotscolormapfind@rgb@X@left 
l.2139 \end{axis}
                 
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Illegal unit of measure (pt inserted).
<to be read again> 
                   \pgfplotscolormapfind@rgb@X@left 
l.2139 \end{axis}
                 
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)

Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!
! Missing number, treated as zero.
<to be read again> 
                   \pgfplotscolormapfind@rgb@X@left 
l.2139 \end{axis}
                 
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Illegal unit of measure (pt inserted).
<to be read again> 
                   \pgfplotscolormapfind@rgb@X@left 
l.2139 \end{axis}
                 
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)

Missing character: There is no p in font nullfont!
Missing character: There is no t in font nullfont!

! Package PGF Math Error: You've asked me to divide `994.48792' by `0.0', but I
 cannot divide any number by `0.0'.

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.2139 \end{axis}
                 
(That was another \errmessage.)

! Arithmetic overflow.
\pgfmathdivide@ ...\pgfmath@x by\c@pgfmath@counta 
                                                  \else \ifdim 0pt>\pgfmath@...
l.2139 \end{axis}
                 
I can't carry out that multiplication or division,
since the result is out of range.


! Package pgfplots Error: No such element: \pgfplotsarrayselect-1\of{pgfpl@cm@j
et}.

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.2139 \end{axis}
                 
(That was another \errmessage.)

! You can't use `the letter b' after \advance.
\pgfplotscolormapfind@precomputed@ ...pgf@counta b
                                                  y1 \ifnum \c@pgf@counta <\...
l.2139 \end{axis}
                 
I'm forgetting what you said and not changing anything.

Missing character: There is no y in font nullfont!
Missing character: There is no 1 in font nullfont!
! Missing number, treated as zero.
<to be read again> 
                   <
l.2139 \end{axis}
                 
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing number, treated as zero.
<to be read again> 
                   \relax 
l.2139 \end{axis}
                 
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

)
Runaway argument?
\pgfplots@EOI \relax \pgffor@continuefalse \fi \fi \ifx \pgfplots@markers@visph
ase@name \ETC.
! File ended while scanning use of \pgfplots@loc@TMPb.
<inserted text> 
                \par 
l.32 ..../pictures/energy_wrt_IIIC_analytical.tex}
                                                  
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! You can't use `\hrule' here except with leaders.
\caption@hrule ->\hrule 
                        \@height \z@ 
l.33 \caption{to be edited}
                           
To put a horizontal rule in an hbox or an alignment,
you should use \leaders or \hrulefill (see The TeXbook).

Missing character: There is no h in font nullfont!
Missing character: There is no e in font nullfont!
Missing character: There is no i in font nullfont!
Missing character: There is no g in font nullfont!
Missing character: There is no h in font nullfont!
Missing character: There is no t in font nullfont!
! Missing number, treated as zero.
<to be read again> 
                   \vskip 
l.33 \caption{to be edited}
                           
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Illegal unit of measure (pt inserted).
<to be read again> 
                   \vskip 
l.33 \caption{to be edited}
                           
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)

! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.33 \caption{to be edited}
                           
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.33 \caption{to be edited}
                           
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.


                           

如果我不改变 matlab 中的颜色图,即注释掉该行

colormap(f3, jet(256));

tex 中没有错误消息。

是否有解决方案可以按照需要实际更改颜色图?

相关内容