Move polyline plotter to its own function