![轴号重叠。有什么方法可以减少刻度数吗?](https://linux22.com/image/449388/%E8%BD%B4%E5%8F%B7%E9%87%8D%E5%8F%A0%E3%80%82%E6%9C%89%E4%BB%80%E4%B9%88%E6%96%B9%E6%B3%95%E5%8F%AF%E4%BB%A5%E5%87%8F%E5%B0%91%E5%88%BB%E5%BA%A6%E6%95%B0%E5%90%97%EF%BC%9F.png)
只想解决这个问题,目前不需要任何花哨的解决方案,只需减少刻度数就足够了,但在 PGF 手册中查找了一段时间后,却无法找到任何接近的方法。有没有什么轴选项可以调整来改变这种情况?
%preamble \usepackage{pgfplots} \pgfplotsset{width=10cm,compat=1.18}
\begin{tikzpicture}
\begin{axis}[
grid,
color = black,
axis y line = middle,
axis x line = bottom,
xlabel=$x$,
ylabel=$y$,
]
\addplot[
domain = 0:0.15,
color = blue!50,
line width = 2pt,
]
{0.5*(1-e^(-0.2))*e^((x-0.1)/0.1)};
\end{axis}
\end{tikzpicture}
答案1
使用xtick={<start value>,<next element>,...,<end value>},
,与 相同ytick
。增量是自动计算的。您也可以指定所有值:ytick={<y1>,<y2>,<y3>},
正如我对 所做的示例ytick
。
MWE 如下:
\documentclass{article}
\usepackage{pgfplots} \pgfplotsset{width=10cm,compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid,
color = black,
axis y line = middle,
axis x line = bottom,
xlabel=$x$,
ylabel=$y$,
xtick={0,0.03,...,0.15},
ytick={0,0.03,0.05, 0.10,0.12,0.14}
]
\addplot[
domain = 0:0.16,
color = blue!50,
line width = 2pt,
]
{0.5*(1-e^(-0.2))*e^((x-0.1)/0.1)};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
您可以使用以下方式指定刻度之间的距离xtick distance
:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid,
color = black,
axis y line = middle,
axis x line = bottom,
xlabel=$x$,
ylabel=$y$,
xtick distance=0.03
]
\addplot[
domain = 0:0.15,
color = blue!50,
line width = 2pt,
]
{0.5*(1-e^(-0.2))*e^((x-0.1)/0.1)};
\end{axis}
\end{tikzpicture}
\end{document}