I would define a triangle "node" using a pic
(see section 18.2 of the tikz manual, version 3.0.1a). For the MWE, we need to specify the height of the triangle and the label, so the pic
needs to accept two arguments. One way to do this is to define a "triangle" pic
as:
\tikzset{
pics/triangle/.style args ={#1,#2}{% pic=triangle{label, height}
code = {
\draw(0,0)node[left]{$#1$} -- ++(#2/2,-#2) -- ++(-#2,0) -- cycle;
}
}
}
This is just "normal" tikz
code that gets placed whenever you "call" the pic
. So, for example, with this in place you could draw a triangle of height 3
and label S
with:
\begin{tikzpicture}
\pic at (0,3) {triangle={S,3}};
\end{tikzpicture}
There are several other ways to "draw" pics
. For example, you can also draw this triangle with \draw(0,3)pic{triangle={S,3}};
.
The easiest way to draw your "squiggly lines" is probably using a "snake decoration" -- see section 48.3 of the manual.
Putting this all together you can produce the diagram

using the code
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, decorations.pathmorphing}
\begin{document}
\tikzset{
triangle/.style = {draw=black, fill=brown!5, thick},
squiggle/.style = {decoration={snake, segment length=5mm}, decorate},
pics/triangle/.style args ={#1,#2}{% pic=triangle{label, height}
code = {
\draw[triangle] (0,0)node[left]{$#1$} -- ++(#2/2,-#2) -- ++(-#2,0) -- cycle;
}
}
}
\begin{tikzpicture}
\pic at (0,3) {triangle={S,3}};
\pic at (0,2) {triangle={P,2}};
\pic at (0,1) {triangle={P,1}};
\draw[squiggle](0,2) -- (0,3);
\draw[squiggle](0,1) -- (0,2);
\draw[-{Latex[open]}] (2,1.5) -- ++(2,0);% using arrows.meta
\pic at (6,3) {triangle={S,3}};
\pic at (6,2) {triangle={P,2}};
\pic at (6,1) {triangle={P,2}};
\pic at (6,0) {triangle={P,2}};
\pic at (6,-1.5) {triangle={P,0.5}};
\foreach \bot/\y in {-1.5/1.5, 0/1, 1/1, 2/1} {
\draw[squiggle](6,\bot) -- ++(0,\y);
}
\end{tikzpicture}
\end{document}
Partly to show how to do it, and partly to fine-tune the diagram (particularly the segment length
for the snake), I have added some styling.