force-distance-diagram.tex 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. \documentclass[varwidth=true, border=2pt]{standalone}
  2. \usepackage{pgfplots}
  3. \pgfplotsset{compat=1.10}
  4. \usepackage{tikz}
  5. \usepgfplotslibrary{fillbetween}
  6. \usepackage{mathtools}
  7. \begin{document}
  8. \begin{tikzpicture}
  9. \begin{axis}[
  10. width=10cm,
  11. height=10cm,
  12. % Grid
  13. grid = major,
  14. % size
  15. xmin= 0, % start the diagram at this x-coordinate
  16. xmax= 4, % end the diagram at this x-coordinate
  17. ymin= 0, % start the diagram at this y-coordinate
  18. ymax= 3, % end the diagram at this y-coordinate
  19. % Legende
  20. legend style={
  21. font=\large\sansmath\sffamily,
  22. at={(0.5,-0.18)},
  23. anchor=north,
  24. legend cell align=left,
  25. legend columns=-1,
  26. column sep=0.5cm
  27. },
  28. % Ticks
  29. tick align=inside,
  30. %minor tick num=3,
  31. minor tick style={thick},
  32. scaled y ticks = false,
  33. xtick={0, 1, 3},
  34. xticklabels={0, $a$, $b$},
  35. ytick=\empty,
  36. axis lines = middle,
  37. axis line style = very thick,
  38. xlabel=$x \coloneqq s$,
  39. x label style={at={(axis description cs:0.88,0.05)},
  40. anchor=north,
  41. font=\boldmath\Large},
  42. ylabel=$y \coloneqq F$,
  43. y label style={at={(axis description cs:0,0.5)},
  44. anchor=south,
  45. rotate=90,
  46. font=\boldmath\Large},
  47. ]
  48. \addplot[domain=0:4, blue, very thick, samples=500, name path=f] {sqrt(x)};
  49. \path[name path=axis] (axis cs:0,0) -- (axis cs:10,0);
  50. \addplot[fill=green,
  51. fill opacity=0.3]
  52. fill between[of=f and axis,soft clip={domain=1:3}];
  53. \end{axis}
  54. \end{tikzpicture}
  55. \end{document}