I'm trying to reproduce this illustration I've made in Inkscape as a tikzpictures for use in LaTex. I've looked a lot at this, and around, but I'm stuck and it's late. Would one of you kind experts out there help me figure out how to make this illustration?
I also looked at this and this, I'll update if I work out some solution that works. IN the meantime please come in here with any suggestions of ideas. Thanks a lot!
Here's a first jab at a compilable MWE,
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{
integral segments/.code={\pgfmathsetmacro\integralsegments{#1}},
integral segments=3,
integral/.style args={#1:#2}{
ybar interval,
domain=#1+((#2-#1)/\integralsegments)/2:#2+((#2-#1)/\integralsegments)/2,
samples=\integralsegments-1,
x filter/.code=\pgfmathparse{\pgfmathresult-((#2-#1)/\integralsegments)/2}
}
}
\begin{tikzpicture}[/pgf/declare function={f=-15*(x-5)+(x-5)^3+50;}]
\begin{axis}[
ticks=none,
domain=0:10,
samples=100,
axis lines=middle
]
\addplot [thick] {f} node[pos=1] (f) {};
\addplot [
red,
integral=2:6
] {f};
\end{axis}
\end{tikzpicture}
\end{document}
@salim-bou and @zarko, I'm amazed, and truly grateful you took the time, and that it didn't take you more then some minutes. Would it be too much to ask how I overlay some text on my graph (obviously not the LaTeX code, but I only have some paint like software to show this here where I am).
\documentclass
and the appropriate packages thatshows what you have tried and sets up the problem and shows exactly what you are stuck with. For instance, can you get as far as drawing the function and the vertical lines ata
andb
? Or is that also a problem? While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.