Plot and calc in the same function