started to implement legend in all plotting functions