Fixed plots legend on group-by when repeated rows for the legend column are present.

This was only partially fixed by 3c6ab78c5c63799d603ea51d56861f34d68502e9.