I want to draw energy cascade graph same as below:
I just assumed that the first part is a constant function equals 4 and the second and the third parts are linear functions with different slopes.
I used the following codes:
\begin{tikzpicture}[
declare function={
func(\x)= (\x>=1) * (4)+
and(\x>1.5, \x<=4) * (-\x/2)+
and(\x>4, \x<=5) * (-\x);
}
]
\begin{axis}[
axis x line=middle, axis y line=middle,
ymin=0, ymax=5, ytick={0,...,5}, ylabel=$\log{E}$,
xmin=0, xmax=5, xtick={-5,...,5}, xlabel=$k$,
]
\pgfplotsinvokeforeach{1, 3, 4}{
\draw[dashed] ({rel axis cs: 0,0} -| {axis cs: #1, 0}) -- ({rel axis cs: 0,20} -| {axis cs: #1, 0});}
\addplot[blue]{func(x)};
\end{axis}
\end{tikzpicture}
But the output gives a continuous curve and also I can't replace the xticks numbers with mathematical phrases.
How can I graph a plot same as the first picture?