Fix ghost lines when switching to line mode and saving figure