I didn't quite understand how does your program works.
When I press space the error 13 occurs.

And put the form's AutoRedraw property set to True so that the axes won't disappear once in a while.

I also work with graphs and stuff like that and I was curious about this program.