使用全新安装的 TeX Live(在撰写本文之前更新)时,axis
环境中的圆圈会变形。考虑以下 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}
显然,这些圆圈根本不是圆圈。我以前没有遇到过这个问题。我在设置新系统时做错了什么吗?
编辑:这不是使用axis equal
与否的问题,因为轴的缩放比例已经大致相等。相反,圆显示为旋转的椭圆,在一个维度上被严重拉伸。
编辑2:这是 \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
答案1
pgfplots
使用未记录的内部 TikZ 命令,这些命令最近已发生更改。维护人员向我承诺会修复此问题,但目前还没有任何进展。
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}
答案2
您需要使用axis equal
。如果两个轴上的 1 个单位的值不相等,则生成的图像将不是圆形。
下面第一张图是原图,第二张是axis equal
应用的:
代码:
\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}
列表文件
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