I managed to draw the entire picture and afterwards rotating it with -45 degrees. This way you can use a random()
as your x
coordinate:
\documentclass[tikz,margin=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[line width = .8pt]
\begin{scope}[rotate=-45]
\draw (0,0) rectangle (-4,5.5);
\coordinate (L1) at (0,1.5);
\coordinate (L2) at (0,3);
\coordinate (L3) at (0,4.5);
\coordinate (L4) at (0,6);
\coordinate (p0) at (-4,0);
\pgfmathparse{4 * random()}
\coordinate (p1) at (L1-|-\pgfmathresult,0);
\pgfmathparse{\pgfmathresult * (1-random())}
\coordinate (p2) at (L2-|-\pgfmathresult,0);
\pgfmathparse{\pgfmathresult * (1-random())}
\coordinate (p3) at (L3-|-\pgfmathresult,0);
\pgfmathparse{\pgfmathresult * (1-random())}
\coordinate (p4) at (L4-|-\pgfmathresult,0);
\foreach \i [remember=\i as \j (initially 0)] in {1,2,3,4}{
\draw (p\j) -- (p\j|-p\i) edge[dashed] ++ (180:0.75) -- (p\i);
\draw (p\i) -- (L\i);
\draw[dashed] (L\i) -- ++(0:0.75) node[pos=1.5]{\( L\i \)};
\path (p\j) -- (L\i) node[midway]{\( A_\i \)};
\draw (p\i) circle (0.5mm) node[above=1mm]{\( P_\i \)};
}
\draw (p4) -| (0,5.5);
\draw[<->] (p1) -- node[auto]{\( x \)} (p1|-0,0);
\draw[<->] ([yshift=-2.5mm]p1) -- node[auto,swap]{\( y \)} ([yshift=-2.5mm]p1-|0,0);
\end{scope}
\end{tikzpicture}
\end{document}
It results in (you might need some compilations to get a good result with the random()
function):

Small update:
This way one can use a certain part of the previous line without having to wait for random()
creating a good value. Also I removed line L4 since that was not drawn in your example image.
\documentclass[tikz,margin=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[line width = .8pt]
\begin{scope}[rotate=-45]
\draw (0,0) rectangle (-4,5.5);
\coordinate (L1) at (0,1.5);
\coordinate (L2) at (0,3);
\coordinate (L3) at (0,4.5);
\coordinate (L4) at (0,6);
\coordinate (p0) at (-4,0);
% \pgfmathparse{4 * random()}
\pgfmathparse{4 * 0.6}
\coordinate (p1) at (L1-|-\pgfmathresult,0);
% \pgfmathparse{\pgfmathresult * (1-random())}
\pgfmathparse{\pgfmathresult * 0.5}
\coordinate (p2) at (L2-|-\pgfmathresult,0);
% \pgfmathparse{\pgfmathresult * (1-random())}
\pgfmathparse{\pgfmathresult * 0.4}
\coordinate (p3) at (L3-|-\pgfmathresult,0);
% \pgfmathparse{\pgfmathresult * (1-random())}
\pgfmathparse{\pgfmathresult * 0.75}
\coordinate (p4) at (L4-|-\pgfmathresult,0);
\foreach \i [remember=\i as \j (initially 0)] in {1,2,3,4}{
\draw (p\j) -- (p\j|-p\i) edge[dashed] ++ (180:0.75) -- (p\i);
\path (p\j) -- (L\i) node[midway]{\( A_\i \)};
\draw (p\i) circle (0.5mm) node[above=1mm]{\( P_\i \)};
}
\foreach \i in {1,2,3}{
\draw (p\i) -- (L\i);
\draw[dashed] (L\i) -- ++(0:0.75) node[pos=1.5]{\( L\i \)};
}
\draw[dashed] (p4) -| (0,5.5);
\draw[<->] (p1) -- node[auto]{\( x \)} (p1|-0,0);
\draw[<->] ([yshift=-2.5mm]p1) -- node[auto,swap]{\( y \)} ([yshift=-2.5mm]p1-|0,0);
\end{scope}
\end{tikzpicture}
\end{document}
