0

I want a node do describe my second function e^{-2t} but it doesn't showing up; this is my code:

\begin{tikzpicture}
            \begin{axis}[
                xmin=-3,xmax=3,
                ymin=-2,ymax=2,
                ticks=none, %elimina i valori numerici
                axis x line=middle,
                axis y line=middle,
                xlabel={$x$},
                ylabel={$y$},
                ]
                \addplot[domain=0:3, samples=100]{exp(-2*x)}node [pos=0.1,anchor=south west]{$e^{-2t}1(t)$};
                \addplot[domain=-0.5:0, samples=100, dashed]{exp(-2*x)}node [pos=-0.1,anchor=south]{$e^{-2t}$};
            \end{axis}
        \end{tikzpicture}

and this is the result: enter image description here

1
  • 3
    Welcome! Your node gets clipped as it is outside of the rectangle plot box (if a negative pos is even a good idea). You could just place a coordinate and then place a node at that coordinate after the axis environment. Nov 6, 2023 at 11:15

1 Answer 1

0

So, the issue that you are having is that the keyword pos is relative to the line you are drawing. You can only set a number from 0 to 1 where 0 means "put my node at the beginning of the line" and 1 means "put it at the end".

In your case because the domain of the second function starts at -0.5 (way out of the axis) your node gets positioned outside of the view area. I would suggest using a value of 0.9. This is the updated code:

\begin{tikzpicture}
\begin{axis}[
    xmin=-3,xmax=3,
    ymin=-2,ymax=2,
    ticks=none, %elimina i valori numerici
    axis x line=middle,
    axis y line=middle,
    xlabel={$x$},
    ylabel={$y$},
    ]
    \addplot[domain=0:3, samples=100]{exp(-2*x)}node [pos=0.1,anchor=south west]{$e^{-2t}1(t)$};
    \addplot[domain=-0.5:0, samples=100, dashed]{exp(-2*x)}node[pos=0.9, anchor=south] {$e^{-2t}$};
\end{axis}
\end{tikzpicture}

And this is how it renders: Graph with two equations and two nodes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .