
Ich habe diese Tex-Datei von Matlab.
\begin{tikzpicture}
\begin{axis}[%
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=1,
xmax=5,
ymin=2,
ymax=10
]
\addplot [color=red,line width=4.0pt,only marks,mark=*,mark options={solid},forget plot]
table[row sep=crcr]{
1 2 \\
2 4 \\
3 6 \\
4 8 \\
5 10 \\
};
\end{axis}
\end{tikzpicture}%
Ich möchte hinzufügen xlabel
und ylabel
darin wie
xmin=1,
xmax=5,
ymin=2,
ymax=10,
xlabel=X,
ylabel=Y,
wenn ich eine andere Latex-Datei wie erwähnt ausführeHier.
\documentclass{minimal}
\newwrite\tempfile
\begin{document}
\immediate\openout\tempfile=lists.tex
\immediate\write\tempfile{xlabel=X,}
\immediate\write\tempfile{ylabel=Y,}
\immediate\closeout\tempfile
\input{lists}
\end{document}
Kann ich diese in bestimmte Zeilen schreiben?
Antwort1
Die Tasten xlabel
und ylabel
können auchdraußender tikzpicture
von Matlab über \pgfplotsset
, zB:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\newdimen\figurewidth
\newdimen\figureheight
\begin{document}
\begingroup
\pgfplotsset{xlabel=$X$, ylabel=$Y$}
\setlength{\figurewidth}{5cm}
\setlength{\figureheight}{5cm}
% Matlab export
\begin{tikzpicture}
\begin{axis}[%
width=\figurewidth,
height=\figureheight,
scale only axis,
xmin=1,
xmax=5,
ymin=2,
ymax=10
]
\addplot [color=red,line width=4.0pt,only marks,mark=*,mark
options={solid},forget plot]
table[row sep=crcr]{
1 2 \\
2 4 \\
3 6 \\
4 8 \\
5 10 \\
};
\end{axis}
\end{tikzpicture}%
\endgroup
\end{document}
Antwort2
Eine Lösung, die nur die Emacs-Funktion „Replace-Regexp“ verwendet:
M-x replace-regexp RET \(ymax=[0-9]+\) RET \1, C-q C-j xlabel=X, C-q C-j ylabel=Y