Updated code - plot legends and titles