Update: added the option for legend for x and y axis.