Fix encoding when using Py2.7; Set plot min, max according to plot data