Working on function for plotting library to get extreme values over a subset of data