
을 사용하여 가능한 한 컴팩트하게 플롯하고 싶습니다 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
설치된 버전이 이지만 버전 1.18의 모든 기능을 사용하도록 요청하려면 옵션을 명시적으로 v1.18.1
설정해야 합니다 . 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}