2

How would you modify the following code so that I insert the arc indicated by the blue line in the diagram? In the normal tikzpicture environment this seems to be quite straightforward, but I am unsure when it comes to graphs.

Thanks

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepackage{fancyhdr}
\usepackage{bigints}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{color,xcolor}
\usepackage{booktabs,array}
\usepackage{hyperref}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usepackage{polynom}
\usepackage{wallpaper}
\usetikzlibrary{shapes.geometric}
\usepgfplotslibrary{fillbetween}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,    % put the x axis in the middle
axis y line=middle,    % put the y axis in the middle
axis line style=thick,
axis line style={->}, % arrows on the axis
xlabel={$x$},          % default put x on x-axis
ylabel={$y$},          % default put y on y-axis
ticks=none,
xmin=-7,xmax=7,
ymin=-7,ymax=7,
clip=false
]
%
\draw[black,thick](axis cs:0,0) circle (1.7cm);
%
%
\node [above] at (axis cs: +0.4,0){$O$};
\node [left,scale=0.9] at (axis cs:  -0.5,-0.4){$\theta$};
%
\node [left,scale=0.9] at (axis cs: -2.4,-3.4){$(x,y)$};
%\node [left] at (axis cs: 0,+1.5){$1$};
%\node [left] at (axis cs: 0,-5.5){$-5$};
\draw[black,thick](axis cs:0,0) -- (axis cs:-2.4,0) -- (axis cs:-2.4,-2.95) --cycle;
\draw[black,thick](axis cs:-2.4,0) rectangle (axis cs:-2,-0.4);
\draw[fill=black](axis cs:-2.4,-2.97) circle (0.4mm);
%
\draw [thick](axis cs:0.92,2) ++(0:1) arc (185:264:0.5);
%\draw [thick](axis cs:2.18,0) ++(0:1) arc (0:95:0.5);
\end{axis}
\end{tikzpicture}
\end{document}

desired output

  • 4
    There is the angles library for that. (Or just draw the arc by using \draw [thick](axis cs:-0.5) arc (180:222:0.5); and if you use a reasonably recent version of pgfplots, \pgfplotset{compat=1.16}, you can drop all the axis cs:.) – user121799 Mar 28 at 22:40
  • 2
    Observe that the bullet is not exactly over the circle. – Sigur Mar 28 at 22:47
4

Sorry, there was a typo in my comment, it should have been \draw [thick](axis cs:-0.5,0) arc (180:222:0.5);, i.e. a ,0 was missing. Here is the version using the angles library.

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{angles,quotes}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,    % put the x axis in the middle
axis y line=middle,    % put the y axis in the middle
axis line style=thick,
axis line style={->}, % arrows on the axis
xlabel={$x$},          % default put x on x-axis
ylabel={$y$},          % default put y on y-axis
ticks=none,
xmin=-7,xmax=7,
ymin=-7,ymax=7,
clip=false
]
%
\draw[black,thick](0,0) coordinate (O) circle (1.7cm);
%
%
\node [above] at ( +0.4,0){$O$};
%
\node [left,scale=0.9] at ( -2.4,-3.4){$(x,y)$};
%\node [left] at ( 0,+1.5){$1$};
%\node [left] at ( 0,-5.5){$-5$};
\draw[black,thick](0,0) -- (-2.4,0) coordinate (X) --
 (-2.4,-2.95) coordinate (xy)  --cycle;
\draw[black,thick](-2.4,0) rectangle (-2,-0.4);
\draw[fill=black](-2.4,-2.97) circle (0.4mm);
%
\draw [thick](0.92,2) ++(0:1) arc (185:264:0.5);
%\draw [thick](2.18,0) ++(0:1) arc (0:95:0.5);
\path pic [draw,angle radius=0.5cm,"{$\theta$}",angle eccentricity=1.5] {angle =
X--O--xy};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.