pgfplots の半対数軸内に楕円を描く

pgfplots の半対数軸内に楕円を描く

片対数軸内に楕円を描こうとしていますpgfplots。楕円の軸は座標軸と平行になるはずですが、選択した半径によっては楕円が回転して表示されます。

MWE は次のとおりです。

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pgfplotsset{width=7cm}
\begin{document}
 \begin{tikzpicture}
  \begin{axis}[ymode=log]
  \addplot coordinates{
    (0,10) (1,300) (2,3347) (3,5000)
  };
  \draw 
  (axis cs:1,300) ellipse [
    x radius = 1, y radius = 10];   
  \end{axis}
 \end{tikzpicture}
\end{document}

生成する

pgfplots 出力のスクリーンショット

楕円を座標軸に揃えて、楕円軸と平行にするにはどうすればよいでしょうか?

答え1

原則として、私は \end{axis} の後にのみ通常の tikz を実行するようにしています。代わりに、後で使用するために座標を保存します。

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pgfplotsset{width=7cm}

\newlength{\rx}
\newlength{\ry}

\begin{document}
 \begin{tikzpicture}
  \begin{axis}[ymode=log]
  \addplot coordinates{
    (0,10) (1,300) (2,3347) (3,5000)
  };
  \coordinate (Center) at (axis cs:1,300);
  \coordinate (Radius) at (axis cs:2,3000);% x+1, y*10 relative to Center
  \end{axis}
  \pgfextractx{\rx}{\pgfpointdiff{\pgfpointanchor{Radius}{center}}{\pgfpointanchor{Center}{center}}}%
  \pgfextracty{\ry}{\pgfpointdiff{\pgfpointanchor{Radius}{center}}{\pgfpointanchor{Center}{center}}}%
  \draw (Center) ellipse [x radius = \rx, y radius = \ry]; 
 \end{tikzpicture}
\end{document}

楕円

関連情報