
\label
및 를 사용하여 \ref
두 개의 y축을 구별할 때 로 그린 표시는 \ref
나머지 레이블과 함께 회전한 후 더 이상 선에 없습니다(아래 예 참조). 어떤 아이디어가 있나요?
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis y line*=left, scale only axis,
ylabel={estimation 2 \ref{pgf:allsamples}}]
\addplot[blue,mark=+] table {data2.csv};
\label{pgf:allsamples}
\end{axis}
\begin{axis}[axis y line*=right, scale only axis,
ylabel={estimation 1 \ref{pgf:swingvotes}}, ylabel near ticks]
\addplot[red,mark=x] table {data1.csv};
\label{pgf:swingvotes}
\end{axis}
\end{tikzpicture}
\end{document}
답변1
실제로 pgfplots에는 버그가 있습니다. 이 \ref
명령은 "tikz 그림 내에서 호출되는지" 확인합니다. 하지만 이 수표에는 버그가 있습니다.~이다tikzpicture 내에서 호출되었지만 노드를 표시하기 위해 tikzpicture가 중단되었습니다.
버그로 인해 레이블이 예기치 않게 변위되었습니다.
버그가 수정될 때까지 다음 해결 방법을 사용할 수 있습니다.
\documentclass{article}
\usepackage{pgfplots}
\def\fixcheck{%
\def\tikzifinpicture##1##2{##2}%
}%
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis y line*=left, scale only axis,
ylabel={\fixcheck estimation 2 \ref{pgf:allsamples}}]
\addplot[blue,mark=+] {x+5};
\label{pgf:allsamples}
\end{axis}
\begin{axis}[axis y line*=right, scale only axis,
ylabel={\fixcheck estimation 1 \ref{pgf:swingvotes}}, ylabel near ticks]
\addplot[red,mark=x] {x};
\label{pgf:swingvotes}
\end{axis}
\end{tikzpicture}
\end{document}
모든 라벨에는 \fixcheck
검사에서 "false"가 반환되도록 하는 매크로가 추가됩니다. 이 경우 \ref
임시 tikzpicture를 추가합니다.