sin-cos.tex 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{0mm}
  4. \usepackage{pgfplots}
  5. \pgfplotsset{compat=1.9}
  6. \begin{document}
  7. \begin{preview}
  8. \begin{tikzpicture}[scale=0.5]
  9. \begin{axis}[
  10. axis x line=middle,
  11. axis y line=middle,
  12. enlarge y limits=true,
  13. enlarge x limits=true,
  14. xmin=0, xmax=2*pi, % x domain
  15. width=15cm, height=8cm, % size of the image
  16. grid = major,
  17. grid style={dashed, gray!30},
  18. ymin=-1, % start the diagram at this y-coordinate
  19. ymax= 1, % end the diagram at this y-coordinate
  20. axis background/.style={fill=white},
  21. ylabel=$y$,
  22. xlabel=$x$,
  23. xtick={0,1.5708,3.14159,4.7123889,6.2830},
  24. xticklabels={$0$,$\frac{\pi}{2}$,$\pi$,$\frac{3\pi}{2}$,$2\pi$},
  25. legend style={at={(0.2,0.37)}, anchor=north}
  26. ]
  27. \addplot[domain=-8:8,thick,samples=200,red] {sin(deg(x))};
  28. \addplot[domain=-8:8,thick,samples=200,blue,dotted] {cos(deg(x))};
  29. \legend{$\sin x$, $\cos x$}
  30. \end{axis}
  31. \end{tikzpicture}
  32. \end{preview}
  33. \end{document}