added generic for printing legends