Mode plot function for main script, written in MATLAB