Add "flatten" function to plot library