Cannot read property 'plot' of undefined