如何修復這個 pgfplot (5x*e^{-x}+1)?

如何修復這個 pgfplot (5x*e^{-x}+1)?
\begin{figure}[H]
    \centering
    \begin{tikzpicture}
    \begin{axis}[xmax=8,ymax=3,
    smooth,
    restrict y to domain=0:4,
    axis lines = left]
    \addplot[red] {5 * x * 1 / pow(e,x) + 1};   \end{axis}
    \end{tikzpicture}
\end{figure}

看起來怎麼樣

但這是錯誤的。它應該是這樣的: 在此輸入影像描述

我需要解決的問題:

  1. 從 y = 0 開始,而不是 x = 1
  2. 使曲線到達 x = 8 而不僅僅是停在中間

就這些。我不想改變網格或其他任何東西。如果你能幫助我,那就太好了。

答案1

始終發布可編譯的程式碼,以便人們回答時有一個起點。

您需要domain您想要繪製的內容。

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[%
    domain=-1:8,
    xmin=-1, xmax=8,
    ymin=0, ymax=3,
    smooth,
    axis lines = left]
    \addplot[red] {5 * x * 1 / pow(e,x) + 1};   
    \end{axis}
    \end{tikzpicture}
\end{document}

圖形

相關內容