Search code examples
latexpgfplots

Graph scaling with LaTeX - Circle becomes Ellipse


I have the following LaTeX code that creates a graph and draws a circle. However, the circle doesn't look like a circle, rather an ellipse. I think this is because of how my graph is setup. Is there any way to keep the current look/scaling of the graph while making the circle look more like a circle(I have included an image of what it looks like below)?

\documentclass[14pt]{article}

\usepackage[letterpaper,bindingoffset=0.2in,%
            left=1in,right=1in,top=1in,bottom=1in,%
            footskip=.25in]{geometry}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[makeroom]{cancel}
\usepackage{tabularx}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
        \begin{axis}[
                xtick distance=10,
                ytick distance=10,
                xmin=-0.0,xmax=144,
                ymin=-0.0,ymax=144,
                grid=both,
                grid style={line width=.1pt, draw=gray!10},
                major grid style={line width=.2pt,draw=gray!50},
                axis lines=middle,
                minor tick num=5,
                enlargelimits={abs=0.5},
                axis line style={latex-latex},
                ticklabel style={font=\tiny,fill=white},
                xlabel style={at={(ticklabel* cs:1)},anchor=north west},
                ylabel style={at={(ticklabel* cs:1)},anchor=south west}
            ]
            
        \draw (axis cs: 70, 70) circle [radius=10];
            
    \end{axis}
\end{tikzpicture}

\end{document}

Result/Output of the above code: enter image description here


Solution

  • If you set the width and height keys to the same value, you'll get your desired circle:

    \documentclass{article}
    
    \usepackage{pgfplots}
    
    \begin{document}
    
    \begin{tikzpicture}
            \begin{axis}[
                    width=\textwidth,
                    height=\textwidth,
                    xtick distance=10,
                    ytick distance=10,
                    xmin=-0.0,xmax=144,
                    ymin=-0.0,ymax=144,
                    grid=both,
                    grid style={line width=.1pt, draw=gray!10},
                    major grid style={line width=.2pt,draw=gray!50},
                    axis lines=middle,
                    minor tick num=5,
                    enlargelimits={abs=0.5},
                    axis line style={latex-latex},
                    ticklabel style={font=\tiny,fill=white},
                    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
                    ylabel style={at={(ticklabel* cs:1)},anchor=south west}
                ]
                
            \draw (axis cs: 70, 70) circle [radius=10];
                
        \end{axis}
    \end{tikzpicture}
    
    
    \end{document}
    

    enter image description here