我需要 y 轴上的值从 0 开始而不是 5。我该如何更改这一点?
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $t$,
ylabel = {\textit{lengte kaars in cm}},
]
%Below the red parabola is defined
\addplot [
domain=0:10,
samples=100,
color=red,
]
{35- 3*x};
\addlegendentry{$\textit{lengte kaars in cm} = 35 - 3t$}
\addplot[mark=*, color=green] coordinates {(0,35)};
\addplot[mark=*, color=blue] coordinates {(2, 29)};
\end{axis}
\end{tikzpicture}
答案1
只需添加轴限制。
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $t$,
ylabel = {\textit{lengte kaars in cm}},
ytick={0,5,...,35}, % <<<<<
ymin=0, % <<<<<
ymax=40, % <<<<< +5
xmin=0, % <<<<<
xmax=11, % <<<<< +1
xtick={0,2,...,10}, % <<<<<
]
%Below the red parabola is defined
\addplot [
domain=0:10,
samples=100,
color=red,
]
{35- 3*x};
\addlegendentry{$\textit{lengte kaars in cm} = 35 - 3t$}
\addplot[mark=*, color=green] coordinates {(0,35)};
\addplot[mark=*, color=blue] coordinates {(2, 29)};
\end{axis}
\end{tikzpicture}
我稍微扩大了最大限制,以便更好地观察箭头。