TransWikia.com

issue with a circle using tikz,beamer and pgfplots

TeX - LaTeX Asked on March 5, 2021

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]{$spacesqrt3$};
    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]{$spacesqrt3$};
    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={$pgfmathprintnumbertick$},

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]{$spacesqrt3$};

but even so it seems not to be working.

One Answer

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={$pgfmathprintnumbertick$},
        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

Correct answer by user228539 on March 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP