4

With a fresh installation of TeX Live (updated just before writing this post), circles in axis environments are distorted. Consider the following MWE:

\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}

\end{document}

The output looks like this: Distorted circles

Obviously, the circles aren't even circles. I haven't encountered this problem before. Did I do anything wrong while setting up my new system?

EDIT: It's not an issue of using axis equal or not since the axes are scaled more or less equally already. Instead, the circles appear as rotated ellipses that are strongly stretched out in one dimension.

EDIT 2: Here's the output of \listfiles:

article.cls    2019/12/20 v1.4l Standard LaTeX document class
  size10.clo    2019/12/20 v1.4l Standard LaTeX file (size option)
pgfplots.sty    2018/03/28 v1.16 Data Visualization (1.16)
graphicx.sty    2019/11/30 v1.2a Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2019/11/30 v1.4a 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    2020/01/08 v3.1.5b (3.1.5b)
     pgf.sty    2020/01/08 v3.1.5b (3.1.5b)
  pgfrcs.sty    2020/01/08 v3.1.5b (3.1.5b)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
pgfrcs.code.tex
 pgfcore.sty    2020/01/08 v3.1.5b (3.1.5b)
  pgfsys.sty    2020/01/08 v3.1.5b (3.1.5b)
pgfsys.code.tex
pgfsyssoftpath.code.tex    2020/01/08 v3.1.5b (3.1.5b)
pgfsysprotocol.code.tex    2020/01/08 v3.1.5b (3.1.5b)
  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    2020/01/08 v3.1.5b (3.1.5b)
pgfcomp-version-1-18.sty    2020/01/08 v3.1.5b (3.1.5b)
  pgffor.sty    2020/01/08 v3.1.5b (3.1.5b)
 pgfkeys.sty
pgfkeys.code.tex
 pgfmath.sty    
pgfmath.code.tex
pgffor.code.tex
tikz.code.tex
l3backend-pdfmode.def    2020-02-03 L3 backend support: PDF mode
supp-pdf.mkii
epstopdf-base.sty    2020-01-24 v2.11 Base part for package epstopdf
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
  • Does this answer help? tex.stackexchange.com/a/323489/15036 TikZ has lots of different coordinate systems... – Thruston Feb 10 at 8:58
  • 1
    All coordinates should already be in the axis coordinate system, specifying axis cs explicitely doesn't help. – Janis91 Feb 10 at 9:04
  • 2
    the unit looks wrong. The circles are large. If I add radius=1.5cm it works. – Ulrike Fischer Feb 10 at 10:12
  • Indeed, specifying the radius in terms of real-world units produces the desired outputs. But shouldn't dimensionless numbers still produce proper circles? – Janis91 Feb 10 at 10:24
9

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}
5

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:

enter image description here

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
  • Thanks for the detailed response, but this clearly was not the issue as you can see from the axis labels in my post. It thus seems there is an issue with my setup. Are you also using the most recent updates? – Janis91 Feb 10 at 9:07
  • @Janis91: The resuls are using code given in the question. I have inclued the output of \listfiles so that you can compare version info. – Peter Grill Feb 10 at 9:16
  • 1
    Thanks. I'm on TikZ v3.1.5b among other differences. I am nonetheless hesitating to suspect a bug in the new TikZ release... – Janis91 Feb 10 at 9:25

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.