"대시 단계"를 사용하여 pgfplots에서 점선 패턴을 이동하는 방법: 범례가 아닌 플롯에서만

"대시 단계"를 사용하여 pgfplots에서 점선 패턴을 이동하는 방법: 범례가 아닌 플롯에서만

에서 언급했듯이이 질문dash phase, 플롯의 대시 사이에서 공백의 위치를 ​​이동하는 데 사용할 수 있습니다 . 그러나 이로 인해 범례의 공백도 이동됩니다.

범례는 변경하지 않고 플롯에서만 공백을 이동할 수 있습니까?

MWE

\begin{tikzpicture}
\begin{axis}[
width=3in,
height=3in
]
\addplot [black, dashed]
table {%
0 0
1 1
2 0
3 -.5
};
\addlegendentry{w/o dash phase}
\addplot [black, dashed, dash phase = 8pt]
table {%
1 0
2 1
3 0
4 -.5
};
\addlegendentry{w/ dash phase}
\end{axis}
\end{tikzpicture}

이는

여기에 이미지 설명을 입력하세요

답변1

이것이 의 목적입니다 legend image post style. 이를 사용하여 를 재설정할 수 있습니다 dash phase.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=3in,
height=3in,legend image post style={dash phase=0pt},
]
\addplot [black, dashed]
table {%
0 0
1 1
2 0
3 -.5
};
\addlegendentry{w/o dash phase}
\addplot [black, dashed, dash phase=8pt]
table {%
1 0
2 1
3 0
4 -.5
};
\addlegendentryexpanded{w/ dash phase}
\end{axis}
\end{tikzpicture}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보