我希望我的图尽可能地填充给定的图形,但找不到如何去除轴节点周围的空白。我已经将 tikzpicture 和轴的内外分离设置为零,但空间仍然存在。
以下是创建该图形的 MWE:
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\DeclareUnicodeCharacter{2212}{−}
\usepgfplotslibrary{groupplots,dateplot}
\usetikzlibrary{patterns,shapes.arrows}
\usetikzlibrary{backgrounds}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[framed,outer sep=0pt, inner sep=0pt]%
\begin{axis}[%
every axis label/.append style={draw},
inner sep=0pt,
outer sep=0pt,
height=5cm,
width=5cm,
tick align=outside,
tick pos=left,
label style={inner sep=0pt},
tick label style={inner sep=1pt},
xlabel={xaxis},
ylabel={yaxis}
]%
\end{axis}%
\end{tikzpicture}%
\end{document}%
答案1
填充来自framed
您tikzpicture
环境的选项。您可以删除此选项,也可以输入以下命令inner frame sep=0pt
来删除填充:
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\DeclareUnicodeCharacter{2212}{−}
\usepgfplotslibrary{groupplots,dateplot}
\usetikzlibrary{patterns,shapes.arrows}
\usetikzlibrary{backgrounds}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[framed, inner frame sep=0pt]%
\begin{axis}[%
every axis label/.append style={draw},
inner sep=0pt,
outer sep=0pt,
height=5cm,
width=5cm,
tick align=outside,
tick pos=left,
label style={inner sep=0pt},
tick label style={inner sep=1pt},
xlabel={xaxis},
ylabel={yaxis}
]%
\end{axis}%
\end{tikzpicture}%
\end{document}%
摘录自钛钾Z & PGF 手册:
答案2
没有axis
额外空间,但背景框架有 - 使用选项tight background
\documentclass[border=0cm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{backgrounds}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[background rectangle/.style={draw=red, thick}, framed, tight background]
\begin{axis}
\end{axis}
\end{tikzpicture}
\end{document}