0

I am trying to graph something similar to the picture posted.

enter image description here

I am having trouble. I am a novice Tikz user but can't seem to figure out how to plot a general equation for a function.

\documentclass[preview]{standalone}
\usepackage tikz
\usetikzlibrary{arrows.meta
\begin{document}
\begin{tikzpicture}
\draw[Triangle-Triangle,thin](-0.5,0)--(3.5,0) node[right]{$t$};
\draw[Triangle-Triangle,thin](0,-1.5)--(0,3.5) node[right]{$j(t)$};

\end{tikzpicture} \end{document}

Zarko
  • 296,517
Nick B
  • 831
  • How is your code relevant for the graph? Do you want the text placed somewhere on the graph? Please show some code trying to do the graph. You could start from your own graph here: https://tex.stackexchange.com/q/585730/8650 – hpekristiansen Feb 08 '22 at 17:11
  • I am sorry. I had the wrong code copied. I fixed it. – Nick B Feb 08 '22 at 17:18
  • Please edit the question to make is readable. You can not insert the image in the middle of the code. – hpekristiansen Feb 08 '22 at 17:22

2 Answers2

3

One more solution using tikz package:

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document} \begin{tikzpicture}[>=Straight Barb] \draw[->] (-0.5,0) -- (3.5,0) node[below left] {time (hours)}; \draw[->] (0,-0.5) -- (0,3.5) node[below left] {$j(t)$}; \draw[->, thick] (0,2.5) .. controls +(2,0) and + (-2,0) .. (3.5,0.5) node[midway,above right] {$j(t)$}; \end{tikzpicture} \end{document}

enter image description here

Zarko
  • 296,517
  • What makes you think that I have not spent hours using those resources, or spending time looking through other posts? I try to find solutions to problems before I post. My posts are usually done because I can't find a solution to what I am working on. – Nick B Feb 24 '22 at 10:53
  • 1
    Dear @NickB, in your question you say "I am a novice Tikz user ...", so I try to help you where you can find information about "plot a general equation " (whatever this mean)". It seems that this you find offending. I'm very sorry for this. I will delete my note by which I try to help you. – Zarko Feb 24 '22 at 13:59
1

As you do not have any function for the graph, I assume you do not care. Here is one way to draw the curve:

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[Triangle-Triangle,thin](-0.5,0)--(3.5,0) node[right]{$t$};
\draw[Triangle-Triangle,thin](0,-1.5)--(0,3.5) node[right]{$j(t)$};
\draw[-Triangle] (0,2.5) to[out=0, in=90] (1.5,1.5) to[out=-90, in=180] (3,0.5);
\end{tikzpicture}
\end{document}

Graph of curve

  • Thank you, I am not sure what the full code means, but I can look at it in depth later. – Nick B Feb 08 '22 at 17:33
  • to[out=-90, in=180] means draw a curve leaving the preceding coordinate at an absolute angle of -90 (horizontal) to the next coordinate entering at an angle of 180 (vertical). Try changing the number to see what they do. – hpekristiansen Feb 08 '22 at 17:48