tikz-sizes.tex 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage{amssymb,amsmath}
  5. \usepackage{pgfplots}
  6. \usepackage{tikz}
  7. \usetikzlibrary{arrows, positioning, calc, intersections, decorations.pathreplacing}
  8. \newcommand\tikzmark[1]{%
  9. \tikz[overlay,remember picture,baseline] \coordinate [anchor=base] (#1);}
  10. \newcommand\DrawBrace[3]{%
  11. \draw [ultra thick, decorate,decoration={brace,amplitude=5pt,mirror,raise=2pt}]
  12. (#1) -- (#2) node [midway,xshift=23pt] {\Huge $\displaystyle #3$};
  13. }
  14. \begin{document}
  15. \begin{preview}
  16. \begin{tikzpicture}
  17. \pgfplotsset{
  18. right segments/.code={\pgfmathsetmacro\rightsegments{#1}},
  19. right segments=3,
  20. right/.style args={#1:#2}{
  21. ybar interval,
  22. domain=#1+((#2-#1)/\rightsegments):#2+((#2-#1)/\rightsegments),
  23. samples=\rightsegments+1,
  24. x filter/.code=\pgfmathparse{\pgfmathresult-((#2-#1)/\rightsegments)}
  25. }
  26. }
  27. \pgfplotsset{
  28. left segments/.code={\pgfmathsetmacro\leftsegments{#1}},
  29. left segments=3,
  30. left/.style args={#1:#2}{
  31. ybar interval,
  32. domain=#1:#2,
  33. samples=\leftsegments+1,
  34. x filter/.code=\pgfmathparse{\pgfmathresult}
  35. }
  36. }
  37. \begin{axis}[
  38. axis lines=middle,
  39. width=15cm, height=15cm, % size of the image
  40. grid = major,
  41. grid style={dashed, gray!30},
  42. xmin= 0, % start the diagram at this x-coordinate
  43. xmax= 3, % end the diagram at this x-coordinate
  44. ymin= 0, % start the diagram at this y-coordinate
  45. ymax= 9, % end the diagram at this y-coordinate
  46. axis background/.style={fill=white},
  47. ylabel=y,
  48. xlabel=x,
  49. tick align=outside,
  50. tension=0.08,
  51. legend style={at={(0.25,0.91)}, anchor=north}]
  52. \addplot[domain=0:3,ultra thin, red, samples=500] {x};
  53. \addplot[domain=0:3,very thin, red, samples=500] {x^2};
  54. \addplot[domain=0:3,thin, red, samples=500] {x^3};
  55. \addplot[domain=0:3,semithick, red, samples=500] {x^4};
  56. \addplot[domain=0:3,thick, red, samples=500] {x^5};
  57. \addplot[domain=0:3,very thick, red, samples=500] {e^x};
  58. \addplot[domain=0:3,ultra thick, red, samples=500] {sqrt(x)};
  59. \legend{ultra thin, very thin, thin, semithick, thick, very thick, ultra thick};
  60. \end{axis}
  61. \end{tikzpicture}
  62. \end{preview}
  63. \end{document}