update plot function