Move _do_gen_matrix out of plotting_utils into utils, and rename it.