force-distance-diagram-constant.tex 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.2, % end the diagram at this x-coordinate
  17. ymin= 0, % start the diagram at this y-coordinate
  18. ymax= 4.2, % 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, 2, 3, 4},
  34. xticklabels={0, $a$, , $b$,},
  35. ytick={0, 1, 2, 3, 4},
  36. yticklabels={, , , $c$, },
  37. axis lines = middle,
  38. axis line style = very thick,
  39. xlabel=$x \coloneqq s$,
  40. x label style={at={(axis description cs:0.86,0.05)},
  41. anchor=north,
  42. font=\boldmath\Large},
  43. ylabel=$y \coloneqq F$,
  44. y label style={at={(axis description cs:0,0.5)},
  45. anchor=south,
  46. rotate=90,
  47. font=\boldmath\Large},
  48. ]
  49. \addplot[domain=0:4, blue, very thick, samples=10, name path=f] {3};
  50. \path[name path=axis] (axis cs:0,0) -- (axis cs:10,0);
  51. \addplot[fill=green,
  52. fill opacity=0.3]
  53. fill between[of=f and axis,soft clip={domain=1:3}];
  54. \end{axis}
  55. \end{tikzpicture}
  56. \end{document}