표시가 있는 pgfplot이 있는 경로를 따라 텍스트를 표시하려면 어떻게 해야 합니까?

표시가 있는 pgfplot이 있는 경로를 따라 텍스트를 표시하려면 어떻게 해야 합니까?

나는 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}

관련 정보