Switched region
Added algorithm to extract median and to make final limit plot