1

Im trying to make a circle like this enter image description here

using the next code

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
         
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
        axis lines = middle,
        xmin=-1, xmax=3, ymin=-1, ymax=7,
        axis equal,
        xlabel = {$x$},
        ylabel = {$y$},
        yticklabels={0,...,5},
        grid=both,
        ]
       \draw (axis cs: 1,4) circle [radius=sqrt(3)];
       \draw (1,4) node[circle,draw,inner sep=1pt,label=below:$\C_C$](z0) {};
       \draw[-stealth] (z0) -- (2.4,3) node[midway,above]{$\space\sqrt3$};
    \end{axis}
\end{tikzpicture}
\end{document}

but when I try to use the beamer class to build the same picture inside a column inside a frame it cant be compiled using pdflatex

   \documentclass{beamer}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{frame}\frametitle{Title}

  \begin{tikzpicture}
    \begin{axis}[
        axis lines = middle,
        xmin=-1, xmax=3, ymin=-1, ymax=7,
        axis equal,
        xlabel = {$x$},
        ylabel = {$y$},
        yticklabels={0,...,5},
        grid=both,
        ]
        %\draw[step=1cm,gray,very thin] grid ;
        \draw (axis cs: 1,4) circle [radius=sqrt(3)]; 
        \draw (1,4) node[circle,draw,inner sep=1pt,label=below:$\C_C$](z0) {};
        \draw[-stealth] (z0) -- (2.4,3) node[midway,above]{$\space\sqrt3$};
    \end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

That gives me two issues one is to find what prevents the compilation and the other is the circle is supposed to be centered in (1,3) but when this coordinates is used the center in the picture appears in (1,2) so it must be compensated using \draw (axis cs: 1,4). What I'm missing in the code to compile and to assign coordinates?

UPDATE
As noted by abcdefg there was a undefined sequence in \C after that it compile as enter image description here

but the center is shifted where is supposed to be using the

    \draw (1,3) node[circle,draw,inner sep=1pt,label=below:$C$](z0) {}; 

and

yticklabels={0,1,2,3,4,5},
yticklabels={$\pgfmathprintnumber\tick$},

UPDATE 2
Well the center is right where is supposed to be, but the arrow isnt starting from the center, as I understand, it is defined the line to start in z0 and go to (2.4,3) . So it can be explicit done by

\draw[-stealth] (1,3) -- (2.4,3) node[midway,above]{$\space\sqrt3$};

but even so it seems not to be working.

7
  • 1
    It complains that \C is not defined (because it is not defined).
    – user228539
    Commented Nov 22, 2020 at 2:18
  • 1
    Let me check the log
    – riccs_0x
    Commented Nov 22, 2020 at 2:19
  • 1
    it says ! Undefined control sequence. <recently read> \C , but then how must define it?
    – riccs_0x
    Commented Nov 22, 2020 at 2:22
  • 1
    How would I know? You use an undefined command, and you need to define it to produce the output you want to get. For the current output you can just drop \C_.
    – user228539
    Commented Nov 22, 2020 at 2:23
  • 1
    BTW, the "strange" shifts are because you use yticklabels={0,...,5},, i.e. you mislabel the y ticks. You can use yticklabel={$\pgfmathprintnumber\tick$}, or similar to get the "correct" y tick labels.
    – user228539
    Commented Nov 22, 2020 at 2:25

1 Answer 1

2

Maybe you are looking for something of this sort (perhaps with \pgfplotsset{compat=1.14} instead of \pgfplotsset{compat=1.17}).

\documentclass{beamer}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{frame}
\frametitle{Title}

  \begin{tikzpicture}
    \begin{axis}[
        axis lines = middle,
        xmin=-1, xmax=3, ymin=-1, ymax=7,
        axis equal,
        xlabel = {$x$},
        ylabel = {$y$},
        yticklabel={$\pgfmathprintnumber\tick$},
        grid=both,
        ]
        %\draw[step=1cm,gray,very thin] grid ;
        \draw (1,3)  node[circle,draw,inner sep=1pt,label=below:{$C$}] (c0){}
             circle [radius={sqrt(3)}]; 
        \draw[-stealth] (c0) to[edge label={$\sqrt{3}$}] ++
        (axis direction cs:{sqrt(3)*cos(-45)},{sqrt(3)*sin(-45)}) ;
    \end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

3
  • 1
    Yep, thanks, thats it, even though I dont understand quite well the stealth options, perhaps Im checking the manual again, tikz isnt my forte.
    – riccs_0x
    Commented Nov 22, 2020 at 3:36
  • 1
    @riccs_0x stealth is just the name of an arrow head.
    – user228539
    Commented Nov 22, 2020 at 3:36
  • 1
    of course, that's why this wasn't making sense to me.
    – riccs_0x
    Commented Nov 22, 2020 at 3:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .