Add condition so legends are not always created