Switch function for plot