{pgfplots} で \draw と \addplot を使用する方法

{pgfplots} で \draw と \addplot を使用する方法

簡単な課題だと思っていましたが、絵が描けないので諦めかけています。単純2点間の矢印。私のMWEは\pgfplotsset{compat=newest}を削除した場合にのみ機能しますそして \draw。pdf出力は不規則な実際、何かが表示されると、矢印が間違った位置にあります。 Stack... で見つかった同様の例はどれも機能しません。 何か基本的なことを見逃しているのではないかと思います。 ご協力ありがとうございます。

私のMWE

\documentclass[border=4pt]{standalone}  
%
\usepackage{pgfplots}
%
\pgfplotsset{compat=newest}  % added without success
%
\begin{document}
%
\begin{tikzpicture}[scale=1.0]
%
\begin{axis}
%
    \addplot[domain=0.5:3, red,  thin] {(x^2-3)/2};
%
\end{axis}
%
\coordinate (orig) (0,0)
%
\coordinate (R) at (2,1/2)
%
\draw [->,thick,blue] (orig) -- (R)
%
\end{tikzpicture}
%
\end{document}

答え1

ようこそ!2つの問題があります。3つのセミコロンと が抜けていますat。しかし、座標がなぜ希望する場所にないのかが疑問だと思います。これは、座標を 内で定義しておらtikzpictureず、 アンビエント 内で定義しているためですaxis。これを修正すると、次のようになります。

\documentclass[border=4pt]{standalone}  
%
\usepackage{pgfplots}
%
\pgfplotsset{compat=newest}  % added without success
%
\begin{document}
%
\begin{tikzpicture}[scale=1.0]
%
\begin{axis}
%
    \addplot[domain=0.5:3, red,  thin] {(x^2-3)/2};
%
\coordinate (orig) at (0,0);
\coordinate (orig') at (0.5,-3/2);
\coordinate (R) at (2,1/2);
\end{axis}
%
\draw [->,thick,blue] (orig') -- (R);
%
\end{tikzpicture}
%
\end{document}

ここに画像の説明を入力してください

関連情報