adds setlegend command in plot