只想解决这个问题,目前不需要任何花哨的解决方案,只需减少刻度数就足够了,但在 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}