forced x to be in ascending order. fixed legend