我是 tikz 新手,下面红色方框部分显示 x、y 轴标签,现在它自动(出现)递增(0,5,10,15,20),我的预期输出是(1,2,3,4)。我正在使用以下代码。我如何更改此代码?
\documentclass{standalone}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage{siunitx}
\sisetup{per-mode=symbol}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=20,
ymin=0,ymax=20,
axis y line*=left,
axis x line*=bottom,
xlabel={$p_0$ (psi)},
xlabel near ticks,
ylabel near ticks
]
\end{axis}
\end{tikzpicture}
\end{document}
答案1
可以定义放置刻度标记的位置以及每个标记的标签:
\documentclass{standalone}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage{siunitx}
\sisetup{per-mode=symbol}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=20,
ymin=0,ymax=20,
axis y line*=left,
axis x line*=bottom,
xlabel={$p_0$ (psi)},
xlabel near ticks,
ylabel near ticks,
xtick={0,5,10,15,20},
xticklabels={0,1,2,3,4},
ytick={0,5,10,15,20},
yticklabels={0,1,2,3,4}
]
\end{axis}
\end{tikzpicture}
\end{document}