0

I am trying to draw a simple tikz-picture including a pgf-plot and some simple tikz-graphics. I want to place a circle so that it touches a parabola at point (0,0). That works well when I use values with units for the radius and position of the center of the circle, but it seems to fail when I use relative coordinates.

Here is my MWE:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[scale=1]
\begin{axis}[%hide axis, 
            xmax=1,xmin=-1,
            ymin=-1,ymax=1]
        \draw (0,0)--(0,1);
        \draw (0,0)--(1,0);
        \addplot[gray,thin,domain=-1:1]{x^2};
        \addplot[gray,thin,domain=-1:1]{-x^2};
        \draw[blue] (0,1cm) circle (1cm);
        \draw[gray,thin] (0,.25) circle (.25);
\end{axis}
\end{tikzpicture}
\end{document}

Image of the elliptic circle produced by my MWE

Any help is appreciated. Thank you in advance!

0

The command \draw[blue] (0,1cm) circle (1cm); draws a circle of radius 1cm.

The command \draw[gray,thin] (0,.25) circle (.25); draws a circle in the coordinate system of the axis. That is, it plots the set of all points that satisfy x^2 + (y-0.25)^2 = 0.25^2 within the axis coordinate system.

Now note that the x scale and the y scale are different in your plot: Both x and y range from -1 to +1, but the width of the plot is bigger than its height. If you want your circle to look like a circle, you need to have the same scale on both axes. See how to keep a 1:1 scale with x and y axis.

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.