plotting median in connected pairs