
を使用して、できるだけコンパクトにプロットしたいと思いますpgfplots
。
次のようなコードがあります:
\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
width=7.5cm,
xlabel={Size of the data set list},
ylabel={Gas cost},
grid=major,
domain=1:100,
xmin=0,xmax=10,
ymin=0,ymax=10,
ytick={0,2,...,12},
samples=21,
]
\addplot {x};
\end{axis}
\end{tikzpicture}
\end{document}
出力は次のようになります。
理由はわかりませんが、y 軸のラベルとその線の間に余分な改行があります。y 軸のラベルと y 軸の線の間の余分なスペースを削除するにはどうすればよいでしょうか。
答え1
インストールされているバージョンが であってもv1.18.1
、バージョン 1.18 のすべての機能を使用するように要求するには、オプションを明示的に設定する必要がありますcompat
。省略すると、ログに次の警告が表示されます。
Package pgfplots Warning: running in backwards compatibility mode
(unsuitable tick labels; missing features). Consider writing
\pgfplotsset{compat=1.18} into your preamble. on input line 4.
MWE:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
width=7.5cm,
xlabel={Size of the data set list},
ylabel={Gas cost},
grid=major,
domain=1:100,
xmin=0,xmax=10,
ymin=0,ymax=10,
ytick={0,2,...,12},
samples=21,
]
\addplot {x};
\end{axis}
\end{tikzpicture}
\end{document}