2

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!

Qrrbrbirlbel
  • 119,821
Arne H.
  • 95
  • 2
  • 7

2 Answers2

1

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.

jarauh
  • 2,762
  • 15
  • 27
1

%I was having a similar issue if you put in the y post scale 1.19 it makes it look pretty much circular, I had seen this done on another stack exchange question, but I do not know which one

modified plot

\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, 
     y post scale=1.19]
        \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}