3

I would like to redraw the following graph on latex. I can make the grids but cannot reproduce the graph correctly. Any ideas on how to reproduce the curved line? enter image description here

1

3 Answers 3

5

Something like this. A tikz solution. where (a) to[in=xx,out=xx] (b) syntax is used.

\draw (0,0) to[out=0, in=-120] (5,2) to[out=60, in=180](10,10)--(13,10);

enter image description here

Code

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[]
\draw(0,0)node[below]{0} --(13,0)node[below]{t,s} ;
\draw(0,0) -- (0,10)node[left]{2.0}node[above]{s,m};
\draw[thick](0,5)node[left]{1.0}--(13,5);
\draw[thick](10,0)node[below]{20}--(10,10);
\draw[thick](5,0)node[below]{10}--(5,10);
\draw[help lines] (0,0) grid (13,10);
\draw (0,0) to[out=0, in=-120] (5,2) to[out=60, in=180](10,10)--(13,10);

\end{tikzpicture}
\end{document}
2
  • What are the numbers 120, 60, 180 etc? The angles or something else? Commented Sep 7, 2014 at 8:33
  • Hi, @shaileshmishra, yes, out means outgoing angle and in means incoming angle.
    – Jesse
    Commented Sep 7, 2014 at 8:42
3

A solution with PSTricks just for fun.

\documentclass[pstricks,border=30pt,12pt,dvipsnames]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}

\FPeval\dx{round(pi*2/3:6)}
\FPeval\dy{round(pi:6)}

\def\f{x-sin(x)}

\psset
{
    algebraic,
    axespos=t,
    labelFontSize=\scriptstyle,
    xAxisLabel=${t,s}$,
    yAxisLabel=${s,m}$,
    xAxisLabelPos={10cm,-12pt},
    yAxisLabelPos={-12pt,10cm},
}

\newpsstyle{mygrid}
{
    dx=\dx,
    dy=\dy,
    labels=none,
    ticksize=0 \psPiTwo,
    subticksize=1,
    subticks=5,
    tickcolor=Maroon,
    subtickcolor=ForestGreen,
}

\begin{document}
\begin{psgraph}[dx=\dx,dy=\dy,Dx=10,Dy=1.0](0,0)(0,0)(\psPiTwo,\psPiTwo){12cm}{!}
    \psaxes[style=mygrid](0,0)(0,0)(\psPiTwo,\psPiTwo)
    \psplot{0}{TwoPi}{\f}
\end{psgraph}
\end{document}

enter image description here

1
  • 1
    Definitely you are a fanatic! of PSTricks, Congratulations.
    – skpblack
    Commented Sep 7, 2014 at 11:30
3

With pgfplots:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  grid=both,
  every axis x label/.style={at={(rel axis cs:0.8,0)},anchor=north west},
  every axis y label/.style={at={(rel axis cs:0,1)},anchor=east},
  xlabel={$t, s$},
  ylabel={$s, m$},
  xticklabel={\pgfmathparse{0.5*\tick*10}\pgfmathprintnumber{\pgfmathresult}},
  yticklabel={\pgfmathparse{\tick/3}\pgfmathprintnumber{\pgfmathresult}},
  xtick={2,4},
  ytick={3,6},
  extra x ticks={1,3,5,6},
  extra x tick style={xticklabel=\empty,grid=major},
  extra y ticks={1,2,4,5},
  extra y tick style={yticklabel=\empty,grid=major},
  enlargelimits=false,
  clip=false,
]
\addplot[blue,thick,samples=100,domain=0:2*pi] {x-sin(deg(x))};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

4
  • 1
    The function x-sin(x) is my pending patent. :-) Commented Sep 7, 2014 at 7:01
  • @cyanide-basedfood I will settle the royalty with Chicken tandoori! Will it work? ;-)
    – user11232
    Commented Sep 7, 2014 at 13:06
  • It is more than enough. :-) Commented Sep 7, 2014 at 15:22
  • x-sin(x) is close, does not exactly reproduce the curve. Commented Sep 8, 2014 at 7:13

You must log in to answer this question.

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