prepare_facets function

Prepare facetting columns in the plotting data.