make the code less static

 xlim calculated based on data