improved plotting with legend