I am trying to draw the graph of sin interval `[-3pi, 3pi]` like this ![image.png](/image?hash=c64358538bb308bf3584392b66b2eed2c6e158837ab7dd9ccdc02c0260f362e0) I tried ``` \documentclass{standalone} \usepackage {pgfplots} \pgfplotsset {compat=1.17} \begin{document} \begin{tikzpicture} \begin{axis} [ domain=-10:10, xmin=-10, xmax=10, ymin=-1.5, ymax=1.5, samples=101, axis lines=center, ytick=\empty, xlabel=$x$, ylabel=$y$, xtick={-9.42478, -6.28319,-4.71239,-3.14,-1.5708,0,1.5708,3.14159,4.71239,6.28319,9.42478}, xticklabels={$-3\pi$,$-2\pi$,$-\frac{3\pi}{2}$,$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$, $\frac{3\pi}{2}$, $2\pi$, $3\pi$ }] \addplot[domain=-3*pi:3*pi,samples=100,red,thick]{sin(deg(x))}; \addplot[domain=-3*pi:3*pi,samples=100,blue,dashed]{-1}; \addplot[domain=-3*pi:3*pi,samples=100,blue,dashed]{1}; \end{axis} \end{tikzpicture} \end{document} ``` I get ![image.png](/image?hash=20ed735a5857d302363def23e48c85fa17076593f89b370e11f78c30748616e4)
Most likely there is a smart way to achieve this with `pgfplots`, but I'm not good with `pgfplots`, so this just uses Ti*k*Z. ``` \documentclass[border=3.14,tikz]{standalone} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \draw[->,>=Stealth] (-3*pi-.5,0) coordinate(-x) -- (3*pi+.5,0) coordinate(+x) node[below]{$x$} ; \draw[->,>=Stealth] (0,-1.5) -- (0,1.5) node[right]{$y$} ; \foreach\y in {1,-1} \draw (-.2,\y) -- (.2,\y) ; \draw[dashed] % points on y axis (0,-1) node[below left]{$-1$} (0,1) node[above left]{$1$} % maxima lines (-x|-{0,1}) -- (+x|-{0,1}) (-x|-{0,-1}) -- (+x|-{0,-1}) % points on x axis (-3*pi,0) node[above]{$-3\pi$} (-2*pi,0) node[above left]{$-2\pi$} (-3*pi/2,0) coordinate(tmp) node[below]{$-\frac{3\pi}{2}$} -- (tmp|-{0,1}) (-pi,0) node[below left]{$-\pi$} (-pi/2,0) coordinate(tmp) node[above]{$-\frac{\pi}{2}$} -- (tmp|-{0,-1}) (0,0) node[below right]{$O$} (pi/2,0) coordinate(tmp) node[below]{$\frac{\pi}{2}$} -- (tmp|-{0,1}) (pi,0) node[above right]{$\pi$} (3*pi/2,0) coordinate(tmp) node[above]{$\frac{3\pi}{2}$} -- (tmp|-{0,-1}) (2*pi,0) node[below right]{$2\pi$} (3*pi,0) node[below]{$3\pi$} ; \draw[red,thick] plot[domain=(-3*pi):(3*pi),samples=101,smooth] (\x,{sin(deg(\x))}) ; \node[above] at (5*pi/2,1) {$f(x) = sin(x)$} ; \end{tikzpicture} \end{document} ``` ![sinplotthingy-1.png](/image?hash=c0c0dd964cf4de3ec58043f7d1ea7f36528289b2b6c9d9d732c88c4816bbc092)
I add `width=18cm, height=4cm` to my question ``` \begin{tikzpicture} \begin{axis} [width=18cm, height=4cm, domain=-3*pi:3*pi, xmin=-3*pi-.5, xmax=3*pi+.5, ymin=-1.5, ymax=1.8, samples=101, axis lines=center, ytick=\empty, xlabel=$x$, ylabel=$y$, xtick={-9.42478,-7.85398, -6.28319,-4.71239,-3.14,-1.5708,0,1.5708,3.14159,4.71239,6.28319,7.85398,9.42478}, xticklabels={$-3\pi$,$-\frac{5\pi}{2}$,$-2\pi$,$-\frac{3\pi}{2}$,$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$, $\frac{3\pi}{2}$, $2\pi$, $\frac{5\pi}{2}$, $3\pi$ }] \addplot[samples=101,red,thick]{sin(deg(x))}; \addplot[domain=-3*pi-.5:3*pi+.5,samples=101,blue,dashed]{-1}; \addplot[samples=101,domain=-3*pi-.5:3*pi+.5,blue,dashed]{1}; \node at (axis cs:0.35, -0.35) {$O$} ; \end{axis} \end{tikzpicture} ``` ![image.png](/image?hash=047c405c6896c7bd202a7f5d14e41296d92b039cfd8b903ffd39af28bef6418e)