Extract similar parts of code in plot_frame.