좌표계 단위로 호 반경 지정

좌표계 단위로 호 반경 지정

이는 후속 조치입니다.pgfplots 및 축 방향 cs를 사용하여 호의 반경을 지정하시겠습니까? MWE를 다음과 같이 변경하려면:

\pgfplotsset{compat=1.10}
\begin{tikzpicture}

\begin{axis}[
      xmin=-20,xmax=20,
    ]
    \addplot{x}; % not important, just to make things show up

  \end{axis}
\draw (axis cs:-16,0) arc[start angle=180, end angle=0, radius=8]; % <-- want to keep units of coordinate system here
\end{tikzpicture}

축 좌표계에서 호 반경을 어떻게 지정합니까? 내가 이미 시도한 것은TikZ에서 임의 점의 x, y 좌표 추출을 사용하여 \pgfextractx. 내 경우에는 길이가 잘못되었습니다.

답변1

이후에는 축 좌표계 값이 손실됩니다 \end{axis}. 이는 이름이 지정된 노드에만 액세스할 수 있음을 의미합니다( axis cs여기에서는 사용할 수 없음).

두 가지 솔루션이 있습니다.

먼저 축과 그림에서 사용되는 단위 길이를 동기화할 수 있습니다(예: x=1cm, y=1cm축 및 에서 사용 tikzpicture). 축은 크기 조정 전략을 무시하므로 다르게 보입니다.

또는 요청한 수량을 기억해 볼 수도 있습니다. 그렇게 할 수 있는 방법은 다음과 같습니다.

\documentclass{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.10}

\begin{document}

\begin{tikzpicture}

\begin{axis}[
      xmin=-20,xmax=20,
      extra description/.code={%
        \pgfplotspointaxisdirectionxy{8}{8}
        \pgfgetlastxy{\X}{\Y}%
        \global\let\radiusX=\X
        \global\let\radiusY=\Y
      },
    ]
    \addplot{x}; % not important, just to make things show up

    \coordinate (P) at (axis cs:-16,0);
  \end{axis}
\draw (P) arc[start angle=180, end angle=0, x radius=\radiusX, y radius=\radiusY]; % <-- want to keep units of coordinate system here
\end{tikzpicture}

\end{document}

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

내 생각은 axis direction cs매크로를 사용하여 평가 \pgfplotspointaxisdirectionxy한 다음 계산된 X 및 Y 좌표를 가져와 두 개의 전역 매크로로 기억하는 것입니다. 이는 나중에 사용됩니다.

관련 정보