sub_plotting factored in a function