Illustrate football team formations on a pitch
Python 2, 401 377 bytes

def g(x,o):
 r=lambda r:[&quot;|&quot;+&quot;  x&quot;*5+&quot;  |&quot;,&quot;|        x        |&quot;,&quot;|     x     x     |&quot;,&quot;|    x   x   x    |&quot;,&quot;|  x   x   x   x  |&quot;][r%5];d=&quot;+&quot;+&quot;-&quot;*17+&quot;+&quot;;h=[d,&quot;|     |  x  |     |&quot;,&quot;|     +-----+     |&quot;]+map(r,x);b=map(lambda r:r.replace(&quot;x&quot;,&quot;o&quot;),[s for s in h[:3]]+map(r,o))[::-1];e=&quot;|&quot;+&quot; &quot;*17+&quot;|&quot;
 if len(x)-4:h.insert(5,e)
 if len(o)-4:b.insert(1,e)
 print&quot;\n&quot;.join(h+[d]+b)

Ungolfed version with test environment here!
Function that takes two lists of the format [defenders, midfielders, midfielders, attackers] while the one midfielder number is optional. Team X (top) comes first, team O (bottom) second.