
我正在使用該decorations.text
庫沿著繪製的路徑設置文本pgfplots
。裝飾效果很好,沒有痕跡,如建議的那樣這個答案,但路徑上有標記,編譯失敗並顯示Package pgf Error: I cannot decorate an empty path \end{axis}
.為什麼,有解決方法嗎?
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[
no markers,
decoration={
text along path,
text={This is my path},
},
postaction={decorate},
] coordinates {(0,0) (10,1)};
% \addplot+[
% mark=*,
% decoration={
% text along path,
% text={This is my path},
% },
% postaction={decorate},
% ] coordinates {(0,1) (10,0)}; %This one fails
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以使用以下命令停用標記裝飾來解決該問題mark options={decoration={name=none}}
:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[
no markers,
decoration={
text along path,
text={This is my path},
},
postaction={decorate},
] coordinates {(0,0) (10,1)};
\addplot+[
mark=*,
decoration={
text along path,
text={This is my path},
},
mark options={decoration={name=none}},
postaction={decorate},
] coordinates {(0,1) (10,0)}; %This one fails
\end{axis}
\end{tikzpicture}
\end{document}