使用 tikz 和 pgfplots 包畫圓

使用 tikz 和 pgfplots 包畫圓

我一直在努力獲得這個

在此輸入影像描述

由於我仍然是使用 tikz 包的業餘愛好者,所以我從某個地方開始。這是我的程式碼,但我得到的只是這個

在此輸入影像描述

 \usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
    ticks=none,
    axis lines = middle,
    axis line style={->},
    ymin=0,
    xmin=-3, xmax=3,
    xlabel={$Y$},
    ylabel={$\pi$},
    axis equal image
]
\draw (axis cs:0,3) circle [blue, radius=1];
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

我真的需要一些幫助,謝謝。

答案1

以下是一些不使用的程式碼pgfplots,您可以在其中添加標籤:

\documentclass[tikz,border=7pt]{standalone}
\pgfmathsetseed{8}
\begin{document}
  \begin{tikzpicture}
    % draw axes
    \draw
      (-4,0) edge[-latex] (4,0)
      (0,-4) edge[-latex] (0,4)
      (0,0)  edge[-latex] (35:2);
    % random points
    \foreach \i in {0,...,30}
      \draw[fill=white] (4*rand,4*rand) circle(2pt);
    % circle
    \draw[red] (0,0) circle (2);
    \foreach \i in {0,8,...,359}
      \fill (\i:2) circle (1.5pt);
  \end{tikzpicture}
\end{document}

在此輸入影像描述

答案2

作為起點,使用polar中的座標pgfplots,以下程式碼可以提供幫助。

\documentclass[margin=3.14159mm]{standalone}
\usepackage{pgf,tikz,pgfplots}
\usepackage{amsmath}
\usetikzlibrary{calc,arrows}
\pgfplotsset{compat=1.12} 
\begin{document}
\begin{tikzpicture}
\def\r{2.5} % Radius of circle
\begin{axis}[
ticks=none,
    axis lines=center,
    axis equal image,
    enlargelimits=true,
    ymin=-3,ymax=3,
    xmin=-3, xmax=3,
    xlabel=$Y$,
    ylabel=$\pi$
     ]
    \addplot[data cs=polar,orange,domain=0:360,samples=360,smooth, ultra thick] (x,{\r});
    \addplot[data cs=polar,domain=0:360,samples=36,mark=*,only marks,black] (x,{\r});
    \draw [-stealth] (0,0)--({\r*cos(25)},{\r*sin(25)})node[midway,above,sloped]{$\varepsilon_R$};
    \draw (0,-1.5) circle (2pt);
    \draw (0,1.5) circle (2pt);
    \draw (1.75,0.25) circle (2pt);
    \draw (-1.75,0.25) circle (2pt);
    \draw (-1.75,-0.25) circle (2pt);
    \draw (1.75,-0.25) circle (2pt);
\end{axis}
\end{tikzpicture}
\end{document}

在此輸入影像描述

相關內容