Distorted circles in axis environment with TikZ
pgfplots
uses undocumented internal TikZ commands, which have recently changed. I was promised a fix by the maintainer but so far nothing is forthcoming.
https://sourceforge.net/p/pgfplots/bugs/232/
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\makeatletter
\def\pgfplots@install@path@replacements{%
\ifpgfplots@path@replace@ellipse
\let\tikz@do@circle=\pgfplots@path@@tikz@do@circle
\let\tikz@do@ellipse=\pgfplots@path@@tikz@do@circle
\expandafter\def\expandafter\pgfinterruptpicture\expandafter{\pgfinterruptpicture
\let\tikz@do@circle=\pgfplots@path@@tikz@do@circle@orig
\let\tikz@do@ellipse=\pgfplots@path@@tikz@do@ellipse@orig
}%
\fi
}%
\let\pgfplots@path@@tikz@do@circle@orig=\tikz@do@circle
\let\pgfplots@path@@tikz@do@ellipse@orig=\tikz@do@ellipse
\let\pgfplots@path@@tikz@do@circle@oldandbroken=\pgfplots@path@@tikz@do@circle
\def\pgfplots@path@@tikz@do@circle#1{\pgfplots@path@@tikz@do@circle@oldandbroken{#1}{#1}}
\def\pgfplots@path@@tikz@do@ellipse#1#2{\pgfplots@path@@tikz@do@circle@oldandbroken{#1}{#2}}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymin=-3, ymax=3,
xmin=-3, xmax=3
]
\draw (1,0) circle [radius=1.5];
\fill (1,0) circle [radius=1];
\end{axis}
\end{tikzpicture}
\end{document}
You need to use axis equal
. If the values of 1 unit on both of the axis are not equal the resulting image won't be a circle.
The first image below is the original, the second one has axis equal
applied:
Code:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymin=-3, ymax=3,
xmin=-3, xmax=3,
]
\draw (1,0) circle [radius=1.5];
\fill (1,0) circle [radius=1];
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
ymin=-3, ymax=3,
xmin=-3, xmax=3,
axis equal,
]
\draw (1,0) circle [radius=1.5];
\fill (1,0) circle [radius=1];
\end{axis}
\end{tikzpicture}
Listfiles
article.cls 2019/10/25 v1.4k Standard LaTeX document class
size10.clo 2019/10/25 v1.4k Standard LaTeX file (size option)
pgfplots.sty 2018/03/28 v1.16 Data Visualization (1.16)
graphicx.sty 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
graphics.sty 2019/11/01 v1.3d Standard LaTeX Graphics (DPC,SPQR)
trig.sty 2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg 2016/06/04 v1.11 sample graphics configuration
pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
tikz.sty 2019/08/03 v3.1.4b (3.1.4b)
pgf.sty 2019/08/03 v3.1.4b (3.1.4b)
pgfrcs.sty 2019/08/03 v3.1.4b (3.1.4b)
everyshi.sty 2001/05/15 v3.00 EveryShipout Package (MS)
pgfrcs.code.tex
pgfcore.sty 2019/08/03 v3.1.4b (3.1.4b)
pgfsys.sty 2019/08/03 v3.1.4b (3.1.4b)
pgfsys.code.tex
pgfsyssoftpath.code.tex 2019/08/03 v3.1.4b (3.1.4b)
pgfsysprotocol.code.tex 2019/08/03 v3.1.4b (3.1.4b)
xcolor.sty 2016/05/11 v2.12 LaTeX color extensions (UK)
color.cfg 2016/01/02 v1.6 sample color configuration
pgfcore.code.tex
pgfcomp-version-0-65.sty 2019/08/03 v3.1.4b (3.1.4b)
pgfcomp-version-1-18.sty 2019/08/03 v3.1.4b (3.1.4b)
pgffor.sty 2019/08/03 v3.1.4b (3.1.4b)
pgfkeys.sty
pgfkeys.code.tex
pgfmath.sty
pgfmath.code.tex
pgffor.code.tex
tikz.code.tex
supp-pdf.mkii
epstopdf-base.sty 2016/05/15 v2.6 Base part for package epstopdf
infwarerr.sty 2016/05/16 v1.4 Providing info/warning/error messages (HO)
grfext.sty 2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty 2016/05/16 v1.4 Define keys (HO)
ltxcmds.sty 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
kvoptions.sty 2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty 2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
iftex.sty 2019/11/07 v1.0c TeX engine tests
pdftexcmds.sty 2019/07/25 v0.30 Utility functions of pdfTeX for LuaTeX (HO)
ifpdf.sty 2019/10/25 v3.4 ifpdf legacy package. Use iftex instead.
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live